本文主要是介绍iOS-NSDate之今天,昨天,这周,这个月,上个月,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
今天跟大家讨论日期的用法,相信大家在项目中,经常会设置一个默认时间段,比如一周前到今天。下面教大家怎么获取前一天,或前一周等等。
比如date 2009-12-11
<code style="padding: 0px; border-width: 0px; background-color: rgb(238, 238, 238); 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;"><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">today </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"2009-12-11 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">yesterday </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"2009-12-10 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">thisWeek </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"2009-12-06 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">lastWeek </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"2009-11-30 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">thisMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"2009-12-01 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">lastMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> dateWithString</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"2009-11-01 00:00:00 +0000"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span></code>
要求出上面的时间
<code style="padding: 0px; border-width: 0px; background-color: rgb(238, 238, 238); 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;"><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSCalendar</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSCalendar</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> currentCalendar</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDateComponents</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:(</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSHourCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSMinuteCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSSecondCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">)</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> fromDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:[[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> alloc</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> init</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setHour</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:-[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components hour</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setMinute</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:-[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components minute</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setSecond</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:-[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components second</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">today </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal dateByAddingComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components toDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:[[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> alloc</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> init</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> options</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="com" style="color: gray; padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">//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; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setHour</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:-</span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">24</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setMinute</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setSecond</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">yesterday </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal dateByAddingComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components toDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> today options</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">0</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSWeekdayCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSYearCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSMonthCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">|</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDayCalendarUnit</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> fromDate</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:[[</span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> alloc</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> init</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setDay</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components weekday</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">1</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">))];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">thisWeek </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setDay</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">7</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">)];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">lastWeek </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setDay</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components day</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">-</span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">1</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">))];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">thisMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components setMonth</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:([</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components month</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">]</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">-</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="lit" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">1</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">)];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSDate</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">*</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">lastMonth </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">=</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">[</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">cal dateFromComponents</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">:</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">components</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">];</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">(@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"today=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">today</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">(@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"yesterday=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">yesterday</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">(@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"thisWeek=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">thisWeek</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">(@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"lastWeek=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">lastWeek</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">(@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"thisMonth=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">thisMonth</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">);</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span><span class="typ" style="color: rgb(43, 145, 175); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">NSLog</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">(@</span><span class="str" style="padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">"lastMonth=%@"</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">,</span><span class="pln" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">lastMonth</span><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;">);</span></code>
<code style="padding: 0px; border-width: 0px; background-color: rgb(238, 238, 238); 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;"><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"> </span></code>
<code style="padding: 0px; border-width: 0px; background-color: rgb(238, 238, 238); 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;"><span class="pun" style="color: rgb(0, 0, 0); padding: 0px; border-width: 0px; background-color: transparent; margin: 0px; vertical-align: baseline;"></span></code><p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="font-size: 24px;">正在学习过程中,<span style="font-family: 'Comic Sans MS';">错误之处请指正,欢迎交流,共同学习;</span></span></p><p class="p1" style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px; font-size: 18px;"> </p><p style="color: rgb(51, 51, 51); font-family: Arial; font-size: 14px; line-height: 26px;"><span style="font-family: 'Comic Sans MS'; font-size: 24px;">欢迎转载分享,请注明出处</span><a target=_blank href="http://blog.csdn.net/xdrt81y" style="color: rgb(51, 102, 153); text-decoration: none;"><span style="font-size: 32px; color: rgb(204, 0, 0);">http://blog.csdn.net/xdrt81y</span></a></p>
这篇关于iOS-NSDate之今天,昨天,这周,这个月,上个月的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!