<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FlexOOP &#187; Flex Date Utils</title>
	<atom:link href="http://flexoop.com/tag/flex-date-utils/feed/" rel="self" type="application/rss+xml" />
	<link>http://flexoop.com</link>
	<description>Flex, AIR, ColdFusion, and everything in between</description>
	<lastBuildDate>Tue, 13 Jul 2010 03:56:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Flex Date Utils &#8211; daysInMonth</title>
		<link>http://flexoop.com/2008/12/flex-date-utils-daysinmonth/</link>
		<comments>http://flexoop.com/2008/12/flex-date-utils-daysinmonth/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 00:33:06 +0000</pubDate>
		<dc:creator>Gareth</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[FlexDateUtils]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[Flex Date Utils]]></category>

		<guid isPermaLink="false">http://flexoop.com/?p=86</guid>
		<description><![CDATA[/** * Gets the days in the month * * @param date The date to check * * @return The number of days in the month */ public static function daysInMonth&#40; date:Date &#41;:Number &#123; // get the first day of the next month var _localDate:Date = new Date&#40; date.fullYear, DateUtils.dateAdd&#40; DateUtils.MONTH, 1, date &#41;.month, 1 [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/**
 * Gets the days in the month
 * 
 * @param date	The date to check
 * 
 * @return		The number of days in the month
 */</span>
<span style="color: #0066CC;">public</span> <span style="color: #0066CC;">static</span> <span style="color: #000000; font-weight: bold;">function</span> daysInMonth<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">date</span>:<span style="color: #0066CC;">Date</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// get the first day of the next month</span>
	<span style="color: #000000; font-weight: bold;">var</span> _localDate:<span style="color: #0066CC;">Date</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Date</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">date</span>.<span style="color: #006600;">fullYear</span>, DateUtils.<span style="color: #006600;">dateAdd</span><span style="color: #66cc66;">&#40;</span> DateUtils.<span style="color: #006600;">MONTH</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #0066CC;">date</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">month</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #808080; font-style: italic;">// subtract 1 day to get the last day of the requested month</span>
	<span style="color: #b1b100;">return</span> DateUtils.<span style="color: #006600;">dateAdd</span><span style="color: #66cc66;">&#40;</span> DateUtils.<span style="color: #006600;">DAY_OF_MONTH</span>, -<span style="color: #cc66cc;">1</span>, _localDate <span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">date</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>I have found method to be quite useful.  It returns the number of days in a month based upon the date passed in.</p>
<p>First I create a date to represent the first of the following month, then I subtract 1 day from that month, and return the day that that date represents, which is now the last day of the month requested.</p>
<p>To use this method, first import the package:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">flexoop</span>.<span style="color: #006600;">utilities</span>.<span style="color: #006600;">dateutils</span>.<span style="color: #006600;">DateUtils</span>;</pre></div></div>

<p>and then:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _dim:<span style="color: #0066CC;">Number</span> = DateUtils.<span style="color: #006600;">daysInMonth</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Date</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">2008</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>_dim will now contain 29, as there were 29 days in February, 2008.</p>
<p>All methods in this series are describing code in the <a href="http://code.google.com/p/flexdateutils/" target="_blank">FlexDateUtils</a> package I put on Google code.</p>
]]></content:encoded>
			<wfw:commentRss>http://flexoop.com/2008/12/flex-date-utils-daysinmonth/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

