<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Date math for lazy people</title>
	<atom:link href="http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Fri, 19 Mar 2010 20:35:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-6898</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Mon, 01 Feb 2010 04:52:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-6898</guid>
		<description>@Maria,

Sorry, I&#039;ve never used LiveCycle... You can try asking them how to structure the code/project in the Adobe LiveCycle blog at http://blogs.adobe.com/livecycle/.

Peter</description>
		<content:encoded><![CDATA[<p>@Maria,</p>
<p>Sorry, I&#8217;ve never used LiveCycle&#8230; You can try asking them how to structure the code/project in the Adobe LiveCycle blog at <a href="http://blogs.adobe.com/livecycle/" rel="nofollow">http://blogs.adobe.com/livecycle/</a>.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maria</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-6896</link>
		<dc:creator>Maria</dc:creator>
		<pubDate>Mon, 01 Feb 2010 01:56:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-6896</guid>
		<description>Hi Peter  i am starting with adobe live cycle i dont know how to included this code in there and how to call the variables, can you give me a hand. Thanks.</description>
		<content:encoded><![CDATA[<p>Hi Peter  i am starting with adobe live cycle i dont know how to included this code in there and how to call the variables, can you give me a hand. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-6894</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Mon, 01 Feb 2010 00:11:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-6894</guid>
		<description>@Maria,

Try this... You can use the &lt;code&gt;time&lt;/code&gt; property of each Date object to convert the date to milliseconds, then subtract the dates and divide by the number of milliseconds in a single day (1000 X 60 X 60 X 24):

&lt;pre lang=&quot;mxml&quot;&gt;
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; creationComplete=&quot;init();&quot;&gt;
    
    &lt;mx:Script&gt;
        &lt;![CDATA[
            public const date1:Date = new Date(2010, 6, 4); /* Jul 4, 2010 */
            public const date2:Date = new Date(2010, 11, 31); /* Dec 31, 2010 */
            
            public const MS_IN_DAYS:Number = 1000 /* ms in sec */ * 60 /*secs in mins */ * 60 /* mins in hr */ * 24 /* hours in day */; 
            
            public function init():void {
                var diffInMS:Number = date2.time - date1.time;
                result.text = (diffInMS / MS_IN_DAYS).toFixed(1);
            }
        ]]&gt;
    &lt;/mx:Script&gt;
    
    &lt;mx:Label text=&quot;Days between {date1.toDateString()} and {date2.toDateString()}:&quot; /&gt;
    &lt;mx:Label id=&quot;result&quot; /&gt;
    
&lt;/mx:Application&gt;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>@Maria,</p>
<p>Try this&#8230; You can use the <code>time</code> property of each Date object to convert the date to milliseconds, then subtract the dates and divide by the number of milliseconds in a single day (1000 X 60 X 60 X 24):</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> creationComplete=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            public const date1:Date = new Date(2010, 6, 4); /* Jul 4, 2010 */</span>
<span style="color: #339933;">            public const date2:Date = new Date(2010, 11, 31); /* Dec 31, 2010 */</span>
&nbsp;
<span style="color: #339933;">            public const MS_IN_DAYS:Number = 1000 /* ms in sec */ * 60 /*secs in mins */ * 60 /* mins in hr */ * 24 /* hours in day */; </span>
&nbsp;
<span style="color: #339933;">            public function init():void {</span>
<span style="color: #339933;">                var diffInMS:Number = date2.time - date1.time;</span>
<span style="color: #339933;">                result.text = (diffInMS / MS_IN_DAYS).toFixed(1);</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> text=<span style="color: #ff0000;">&quot;Days between {date1.toDateString()} and {date2.toDateString()}:&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;result&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maria</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-6892</link>
		<dc:creator>Maria</dc:creator>
		<pubDate>Sun, 31 Jan 2010 23:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-6892</guid>
		<description>can someone please help me . i need to know how to calculate the number of days between two different dates?
Cheers,
Maria</description>
		<content:encoded><![CDATA[<p>can someone please help me . i need to know how to calculate the number of days between two different dates?<br />
Cheers,<br />
Maria</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marshall</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-6846</link>
		<dc:creator>Marshall</dc:creator>
		<pubDate>Mon, 25 Jan 2010 23:26:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-6846</guid>
		<description>Yet again this blog saves my ass. Thanks a lot for your efforts here!</description>
		<content:encoded><![CDATA[<p>Yet again this blog saves my ass. Thanks a lot for your efforts here!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gareth Arch</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-6084</link>
		<dc:creator>Gareth Arch</dc:creator>
		<pubDate>Wed, 21 Oct 2009 18:25:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-6084</guid>
		<description>I&#039;ve written a pretty full featured FlexDateUtils library that handles dateAdd (plus a slew of other date functions) with constants to help reference the various dateparts.  It&#039;s posted in the google code base at http://code.google.com/p/flexdateutils/ or Ray Camden&#039;s riaforge, flexdateutils.riaforge.org  Hopefully it&#039;ll be useful to some of the posters here.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve written a pretty full featured FlexDateUtils library that handles dateAdd (plus a slew of other date functions) with constants to help reference the various dateparts.  It&#8217;s posted in the google code base at <a href="http://code.google.com/p/flexdateutils/" rel="nofollow">http://code.google.com/p/flexdateutils/</a> or Ray Camden&#8217;s riaforge, flexdateutils.riaforge.org  Hopefully it&#8217;ll be useful to some of the posters here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Oxley</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-5835</link>
		<dc:creator>Tim Oxley</dc:creator>
		<pubDate>Tue, 22 Sep 2009 02:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-5835</guid>
		<description>Have you seen the adobe version of this in the fr.runtime.DateTimeFunc class?

http://livedocs.adobe.com/flex/gumbo/langref/index.html?fr/runtime/lib/DateTimeFunc.html

I&#039;m not sure where to get this from, it doesn&#039;t appear to be in the flex4 svn source or anywhere else reasonable... apparently, based on the package name, it has something to do with &#039;fiber&#039; which I think is something to do with live cycle 3... anyway, if someone knows anything more about this and could direct us to a download of this package, that&#039;d be rad. 

Regards, 

Tim</description>
		<content:encoded><![CDATA[<p>Have you seen the adobe version of this in the fr.runtime.DateTimeFunc class?</p>
<p><a href="http://livedocs.adobe.com/flex/gumbo/langref/index.html?fr/runtime/lib/DateTimeFunc.html" rel="nofollow">http://livedocs.adobe.com/flex/gumbo/langref/index.html?fr/runtime/lib/DateTimeFunc.html</a></p>
<p>I&#8217;m not sure where to get this from, it doesn&#8217;t appear to be in the flex4 svn source or anywhere else reasonable&#8230; apparently, based on the package name, it has something to do with &#8216;fiber&#8217; which I think is something to do with live cycle 3&#8230; anyway, if someone knows anything more about this and could direct us to a download of this package, that&#8217;d be rad. </p>
<p>Regards, </p>
<p>Tim</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-5544</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Thu, 03 Sep 2009 00:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-5544</guid>
		<description>@Didi,

I believe a few comments above deal with getting week numbers, but you could try something like this (relatively untested) code:

&lt;pre lang=&quot;mxml&quot;&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private const MILLISECONDS_IN_WEEK:uint = 1000 /* milliseconds */ * 
                                                        60 /* seconds */ * 
                                                        60 /* minutes */ * 
                                                        24 /* hours */ * 
                                                         7 /* days */;

            private function calculateWeekNumber(dat:Date):int {
                var jan1:Date = new Date(dat.fullYear, 0, 1);
                var diff:Number = dat.time - jan1.time;
                var diffInWeeks:uint = diff / MILLISECONDS_IN_WEEK;
                return diffInWeeks;
            }
        ]]&gt;
    &lt;/mx:Script&gt;
    
    &lt;mx:DateField id=&quot;datField&quot; /&gt;

    &lt;mx:Label id=&quot;lbl&quot; text=&quot;Week: {calculateWeekNumber(datField.selectedDate)}&quot; /&gt;
    
&lt;/mx:Application&gt;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>@Didi,</p>
<p>I believe a few comments above deal with getting week numbers, but you could try something like this (relatively untested) code:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            private const MILLISECONDS_IN_WEEK:uint = 1000 /* milliseconds */ * </span>
<span style="color: #339933;">                                                        60 /* seconds */ * </span>
<span style="color: #339933;">                                                        60 /* minutes */ * </span>
<span style="color: #339933;">                                                        24 /* hours */ * </span>
<span style="color: #339933;">                                                         7 /* days */;</span>
&nbsp;
<span style="color: #339933;">            private function calculateWeekNumber(dat:Date):int {</span>
<span style="color: #339933;">                var jan1:Date = new Date(dat.fullYear, 0, 1);</span>
<span style="color: #339933;">                var diff:Number = dat.time - jan1.time;</span>
<span style="color: #339933;">                var diffInWeeks:uint = diff / MILLISECONDS_IN_WEEK;</span>
<span style="color: #339933;">                return diffInWeeks;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DateField</span> id=<span style="color: #ff0000;">&quot;datField&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Label</span> id=<span style="color: #ff0000;">&quot;lbl&quot;</span> text=<span style="color: #ff0000;">&quot;Week: {calculateWeekNumber(datField.selectedDate)}&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Didi</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-5543</link>
		<dc:creator>Didi</dc:creator>
		<pubDate>Wed, 02 Sep 2009 20:44:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-5543</guid>
		<description>hi Peter,

I am trying to get the week no of a date.

For example,  

Date: 3rd September 2009
Week: 36

Date: 7 September 2009
Week: 37
.
.
.
Date:  29 December 2009
Week: 53

do u have an idea where i can get the week no from a date?

Thanks in advance for your help</description>
		<content:encoded><![CDATA[<p>hi Peter,</p>
<p>I am trying to get the week no of a date.</p>
<p>For example,  </p>
<p>Date: 3rd September 2009<br />
Week: 36</p>
<p>Date: 7 September 2009<br />
Week: 37<br />
.<br />
.<br />
.<br />
Date:  29 December 2009<br />
Week: 53</p>
<p>do u have an idea where i can get the week no from a date?</p>
<p>Thanks in advance for your help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nate alberg</title>
		<link>http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/comment-page-1/#comment-5108</link>
		<dc:creator>nate alberg</dc:creator>
		<pubDate>Wed, 12 Aug 2009 01:12:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/date-math-for-lazy-people/#comment-5108</guid>
		<description>Oh.. you may want this too.
&lt;pre&gt;    
    public static const MS_IN_SEC:int = 1000;
    public static const MS_IN_MIN:int = 1000 * 60;
    public static const MS_IN_HOUR:int = 1000 * 60 * 60;
    public static const MS_IN_DAY:int = 1000 * 60 * 60 * 24;
    public static const MS_IN_YEAR:Number = 1000 * 60 * 60 * 24 * 365;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Oh.. you may want this too.</p>
<pre>
    public static const MS_IN_SEC:int = 1000;
    public static const MS_IN_MIN:int = 1000 * 60;
    public static const MS_IN_HOUR:int = 1000 * 60 * 60;
    public static const MS_IN_DAY:int = 1000 * 60 * 60 * 24;
    public static const MS_IN_YEAR:Number = 1000 * 60 * 60 * 24 * 365;
</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
