与 iphone SDK 比较时间/日期
我对整个 iPhone SDK 和 Objective C 都很陌生,但已经成功获得了 3 次,其中两次是从 RSS feed 中提取的,一次是从 iphone 中提取的。 我目前有:日出、日落和当前时间设置如下:
6:51 am //Sunrise
7:36 pm //Sunset
11:34 AM //Current time
我正在尝试找出最好的方法来确定现在是白天还是晚上? 对此欢迎任何帮助,提前致谢。
I am new to the whole iPhone SDK and objective C, but have managed to get three times, two pulled from RSS feed, and one from the iphone.
I currently have: sunrise, sunset and current time set like:
6:51 am //Sunrise
7:36 pm //Sunset
11:34 AM //Current time
I am trying to work out the best approach to find out if its day or night?
Any help on this welcome, thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 NSDateFormatter从您的日期创建 NSDate 对象。
在 NSDate你有:
您可以使用
earlierDate
、laterDate
和compare
。白天您想要:
您想要的夜间
伪代码:)
Use NSDateFormatter to create NSDate objects from your dates.
In NSDate you have:
earlierDate
,laterDate
andcompare
that you can use.For day time you want:
for night time you want:
Pseudo code :)