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

2023-11-21 23:48

本文主要是介绍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之今天,昨天,这周,这个月,上个月的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/405938

相关文章

安卓链接正常显示,ios#符被转义%23导致链接访问404

原因分析: url中含有特殊字符 中文未编码 都有可能导致URL转换失败,所以需要对url编码处理  如下: guard let allowUrl = webUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {return} 后面发现当url中有#号时,会被误伤转义为%23,导致链接无法访问

【iOS】MVC模式

MVC模式 MVC模式MVC模式demo MVC模式 MVC模式全称为model(模型)view(视图)controller(控制器),他分为三个不同的层分别负责不同的职责。 View:该层用于存放视图,该层中我们可以对页面及控件进行布局。Model:模型一般都拥有很好的可复用性,在该层中,我们可以统一管理一些数据。Controlller:该层充当一个CPU的功能,即该应用程序

iOS剪贴板同步到Windows剪贴板(无需安装软件的方案)

摘要 剪贴板同步能够提高很多的效率,免去复制、发送、复制、粘贴的步骤,只需要在手机上复制,就可以直接在电脑上 ctrl+v 粘贴,这方面在 Apple 设备中是做的非常好的,Apple 设备之间的剪贴板同步功能(Universal Clipboard)确实非常方便,它可以在 iPhone、iPad 和 Mac 之间无缝传输剪贴板内容,从而大大提高工作效率。 但是,iPhone 如何和 Wind

iOS项目发布提交出现invalid code signing entitlements错误。

1、进入开发者账号,选择App IDs,找到自己项目对应的AppId,点击进去编辑, 2、看下错误提示出现  --Specifically, value "CVYZ6723728.*" for key "com.apple.developer.ubiquity-container-identifiers" in XX is not supported.-- 这样的错误提示 将ubiquity

我的第一次份实习工作-iOS实习生-第三个月

第三个月 这个月有一个考核项目,是一个电子书阅读器,组长说很重要,是我的实习考核项目。 我的项目XTReader,这是我参考网上的一些代码,和模仿咪咕阅读做的,功能还不完善,数据的部分是用聚合数据做的。要收费的。   还有阅读页面,基本功能实现了一下。使用了autolayout,自适应布局,也是第一次用网络,第一次用数据库,第一次用自动布局。还有很多不足。 做了一周多,有个问题一直没

我的第一次份实习工作-iOS实习生-公司使用过的软件

bittorrentsync 素材,文件同步软件 cornerstone svn 软件开发合作 mark man 测量坐标的软件 SQLLite Manager 数据库操作软件

我的第一次份实习工作-iOS实习生-第二个月

第二个月 来公司过了一个月了。每天早上9点上班,到晚上6.30下班,上下班要指纹打卡,第一个月忘了打卡好多次(),然后还要去补打卡单。公司这边还安排了,工资卡办理,招商银行卡。开了一次新员工大会,认识了公司的一些过往,公司的要求等,还加了一下公司的企业QQ,还有其他的羽毛球群,篮球群。我加了下羽毛球群,也去打了一两次。第二个月的感受,感觉跟组里面的交流跟沟通都好少,基本上还有好多人不认识。想想也

我的第一次份实习工作-iOS实习生-第一个月

实习时间:2015-08-20 到 2015-12-25  实习公司;福建天棣互联有限公司 实习岗位:iOS开发实习生 第一个月: 第一天来公司,前台报道后,人资带我去我工作的地方。到了那,就由一个组长带我,当时还没有我的办公桌,组长在第三排给我找了一个位置,擦了下桌子,把旁边的准备的电脑帮我装了下,因为学的是iOS,实习生就只能用黑苹果了,这是我实习用的电脑。 帮我装了一下电脑后,开机

iOS如何隐藏系统状态栏

这里主要说明一下iOS7系统给状态栏的适配及隐藏带来的改变。 变化一: 不隐藏状态栏的情况下,StatusBar会直接显示在当前页面上,当前页面的会延伸到 StatusBar下方,顶到最上头。 这种显示方式在iOS7上是无法改变的,也无法通过设置或者配置类达到iOS6的状态栏效果。       所以在iOS7上进行页面布局的时候要考虑

ios %.2f是四舍五入吗?

实事上这个“四舍五入”并不是数学上的“四舍五入”,而是“四舍六入五成双”,英文中被称为”round half to even”或”Banker’s rounding”。 “四舍六入五成双”是指,当保留精度的下一位不是5时,按正常的四舍五入;当保留精度的下一位是5时,如果5的后面为0则舍弃;而如果5的后面还有大于0的部分时,则无论5的前一位是奇数还是偶数,都进行进位。 1.当保留精度的下一位不是