有人可以指向我几个月的源代码吗?

时间:2011-05-16 15:14:15

标签: c ios calendar

我正在构建需要最少日历的iOS应用。真的是这个月的几天。有没有人遇到过简单的源代码 - c代码很好 - 当给出一个月和一年的时候可以生成一个月的正确日期?

谢谢,
道格

2 个答案:

答案 0 :(得分:3)

查看IOS日期和时间编程指南http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/DatesAndTimes/Articles/dtCalendars.html#//apple_ref/doc/uid/TP40003470-SW1

他们有以下示例显示如何从NSDate获取星期几:

NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc]
                     initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekdayComponents =
                [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:today];
NSInteger day = [weekdayComponents day];
NSInteger weekday = [weekdayComponents weekday];

答案 1 :(得分:0)

我发现了这个:http://www.codecogs.com/code/units/date/daysinmonth.php与谷歌。我不知道你是否能用它做点什么。可悲的是,你必须在网站上注册才能下载完整的资源......