nsdatecomponents

    0热度

    2回答

    我想比较2个日期,但我正在获得1每天不足 这里是一个片段: NSDateComponents* dateComponents = [[NSDateComponents alloc] init]; [dateComponents setYear: 2014]; [dateComponents setMonth: 1]; [dateComponents setDay: 31]; NSCal

    1热度

    2回答

    我正在使用UIPickerView来显示小时选择,它想从00:00到23:00,但是我明显做错了,因为我得到11:58到10 :58。这是我在做什么: - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { NSC

    0热度

    1回答

    我试图从NSDate获取小时组件。 这里是我做的: NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [calendar setTimeZone:[NSTimeZone timeZoneWithName:@"GMT+1"]]; NSDateCom

    3热度

    1回答

    我想将NSDate从一个时区转换为另一个时区。 这里是我的代码: NSDate* convertTime(NSDate* fromDate, NSTimeZone* fromTimeZone, NSTimeZone* toTimeZone) { if (fromTimeZone == toTimeZone) { return fromDate; } NS

    0热度

    1回答

    我是iOS的新手,我很难在2年内获得数月和数年的收入。我把它们放入NSArray。我所能得到的只有一年,但除此之外,这些年份不会增加以反映年份的变化。请帮忙?由于 NSDate *todayDate = [NSDate date]; NSDateComponents *todayComponents=[[NSCalendar currentCalendar] components:NSYear

    44热度

    5回答

    在Julian Day计算器上编写一些单元测试时,我发现1847年12月2日之前的日期被NSDate错误地初始化。他们似乎有75秒的时间。我无法找到指向那天的任何东西(这是格雷戈里日历截止之后)。这是一个错误还是有历史的日历调整,我没有遇到? int main(int argc, const char * argv[]) { @autoreleasepool { NSCa

    0热度

    1回答

    IM盘创建一个firedate吃午饭的通知,我得去currente时间 NSDate *now = [NSDate date]; ,但我需要将它与另一天设置为比较例如上午06时55分, 我已经使用这个 [NSDateComponets] 和 int hour=20; int minute=40; int second=00; NSDateFormatter *tempFormatter

    2热度

    2回答

    说我有下面的代码初始化一个NSDateComponents: NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [[NSDateComponents alloc] init]; [components setYear:1987]; [components setMonth:

    4热度

    1回答

    说我有个约会,我希望做两件事情: 重置小时到指定的一个。 增加一定量的日子。 通过阅读文档,它看起来像你需要使用两个不同的步骤: // Step 1: Get today at 9 AM. NSDateComponents *todayComponents = [[NSCalendar currentCalendar] components:(NSCalendarUnitSecond | NSC

    0热度

    3回答

    我有一个任务计算在某个截止日期到期之前剩余的天数。例如:从今天开始我有10个工作日的截止日期(让我们假设这是一个星期一)。我需要计算在截止日期到期之前剩余的日历天数。这意味着我需要查看这段时间内有多少个周末,并将它们添加到“剩余天数”结果中(在我们的具体示例中应该是12天,因为在此时间段内只有一个周末)。 我该如何在iOS上做到这一点? 让我知道你是否需要更多的澄清