2 个 NSDate 之间的差异(不包括周末)?
对于熟悉 Excel 的人,我尝试在 Cocoa 中使用类似的 NETWORKDAYS 函数。
任何人都可以帮助我构建一个 NSDate 类别所需的信息类型,该类别只能为我提供每周两个日期的工作日吗?
非常感谢 尼克
For those familiar with Excel, I'm trying to use a similiar NETWORKDAYS function within Cocoa.
Can anyone help with the type of info I'll need to construct an NSDate catagory that can give me only the working days betweek two dates?
many thanks
Nik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道我给出的并不是优化的,但这只是为了给你一种探索的方式。
您可以像这样使用 NSCalendar 和 NSDateComponents :(
请参阅 日历、日期组件和日历单位)
从那里开始,您从第一个日期开始,每天迭代此操作,直到结束日期并使用您的工作日可以确定这一天是否是周末。 (我重复一遍,这没有优化,但它只是一个轨道)
I know that I'll give is not optimized, but it's just to give you a way to explore.
You can use the NSCalendar and the NSDateComponents like that:
(see Calendars, Date Components, and Calendar Units)
From there you start from your first date and you iterate this for each day until your end date and using the weekday you can determine if the day is during a weekend or not. (I repeated that's not optimized but it's just a track)