IOS-NSDate之今天,昨天,这周,这个月,上个月

今天跟大家讨论日期的用法,相信大家在项目中,经常会设置一个默认时间段,比如一周前到今天。下面教大家怎么获取前一天,或前一周等等。

比如date 2009-12-11

<code style="padding: 0px; border-width: 0px; margin: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; vertical-align: baseline; background-color: rgb(238, 238, 238);"><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">today </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"2009-12-11 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
 </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">yesterday </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"2009-12-10 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
 </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">thisWeek </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"2009-12-06 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
 </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">lastWeek </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"2009-11-30 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
 </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">thisMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"2009-12-01 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
 </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">lastMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"2009-11-01 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span></code>

要求出上面的时间

<code style="padding: 0px; border-width: 0px; margin: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, serif; vertical-align: baseline; background-color: rgb(238, 238, 238);"><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSCalendar</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSCalendar</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> currentCalendar</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDateComponents</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:(</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSHourCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSMinuteCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSSecondCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">)</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> fromDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:[[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> alloc</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> init</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setHour</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:-[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components hour</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setMinute</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:-[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components minute</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setSecond</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:-[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components second</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">today </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal dateByAddingComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components toDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:[[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> alloc</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> init</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> options</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="com" style="color: gray; padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">//This variable should now be pointing at a date object that is the start of today (midnight);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setHour</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:-</span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">24</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setMinute</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setSecond</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">yesterday </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal dateByAddingComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components toDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> today options</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

components </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSWeekdayCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSYearCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSMonthCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDayCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> fromDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:[[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> alloc</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> init</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setDay</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components weekday</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">1</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">))];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> 
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">thisWeek  </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setDay</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">7</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">)];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">lastWeek  </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setDay</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">-</span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">1</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">))];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> 
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">thisMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components setMonth</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components month</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="lit" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">1</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">)];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> 
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">lastMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">

</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">(@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"today=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">today</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">(@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"yesterday=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">yesterday</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">(@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"thisWeek=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">thisWeek</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">(@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"lastWeek=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">lastWeek</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">(@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"thisMonth=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">thisMonth</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">
</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">(@</span><span class="str" style="padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">"lastMonth=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">lastMonth</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; margin: 0px; vertical-align: baseline; background-color: transparent;">);</span></code>

 

正在学习过程中,错误之处请指正,欢迎交流,共同学习;


欢迎转载分享,请注明出处http://blog.csdn.net/xdrt81y



你可能感兴趣的:(IOS-NSDate之今天,昨天,这周,这个月,上个月)