nsdatecomponents相关内容
当地通知应该在2021年9月25日发出。下面是Fire Time的打印对象 ▿年:2021年月:9天:26 isLeapMonth:False 年份:2021年 月份:9 天:25 isLeapMonth:False let content = UNMutableNotificationContent() content.title = "Test title" conte
..
我想得到一周的第一天和最后一天.但我的结果与苹果的文档不匹配:https://developer.apple.com/documentation/foundation/nsdatecomponents/1410442-工作日 这是我的功能: func startAndEndDateOfWeek(weekOfYearWithYear: (week: Int,year: Int)) ->(开始
..
我有一个方法的这个子集,需要获取当前月份的第一天. NSDate *today = [NSDate 日期];//正确返回 2013 年 2 月 28 日NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];NSDateComponents *components =
..
我有两个日期字符串,我想得到两个日期之间的时间.例如, NSString *startDate = @"25-01-2014";NSString *endDate = @"02-02-2014"; 在两个日期之间将是 (26-01-2014, 27-01-2014, 28-01-2014.......)最好也包括 startDate 和 endDate.我设法找到的大多数问题都询问了天数.但我
..
我使用以下代码创建了一个 DateComponents 实例: 让 dateComponents = DateComponents(日历:.current,时区:Calendar.current.timeZone,时代:无,年份:无,月份:无,日:无,小时:9,分钟:0,第二个:0,纳秒:0,工作日:2,工作日序数:无,季度:零,weekOfMonth:无,weekOfYear:无,yearFo
..
在没有其他信息的情况下,如何获取 NSDate 对象的年/月/日?我意识到我可能可以用类似的东西来做到这一点: NSCalendar *cal = [[NSCalendar alloc] init];NSDateComponents *components = [cal components:0 fromDate:date];int year = [组件年份];int 月 = [组件月];int
..
我相信这已经被问过好几次了,但没有明确的答案. 有两种安排时间通知的方法:UNCalendarNotification 和 UNTimeIntervalNotificationTrigger. 为特定时间和一周中的某天安排通知是微不足道的,与每月的特定日期相同,但针对特定时间(每 n 天)安排通知并不是那么简单. 例如每 5 天 11:00. UNTimeIntervalN
..
我有以下 Swift (Swift 3) 函数来使用日期组件 (DateComponents) 创建日期 (Date). func makeDate(year: Int, Month: Int, day: Int, hr: Int, min: Int, sec: Int) ->NSDate {让日历 = NSCalendar(calendarIdentifier: .gregorian)!让组件
..
我正在尝试使用此函数从 Swift 中的birthdayDate 计算年龄: var calendar : NSCalendar = NSCalendar.currentCalendar()var dateComponentNow : NSDateComponents = calendar.components(NSCalendarUnit.CalendarUnitYear,从日期:生日,至今:
..
我有两个 NSDateComponents,我想要这两个之间的所有 NSDateComponents,我尝试了以下方法, NSDateComponents *first = ...;NSDateComponents *second = ...;BOOL boolDone = 否;而 (!boolDone) {[数组添加对象:第一个];第一天+=1;NSLog(@"%@",first);if([[
..
如何将以下字符串“10 月 24 日,星期一 12:30 AM EST"转换为 NSDateFormat. 我试过这个代码 NSDateFormatter *dateformat=[[NSDateFormatter alloc]init];[dateformat setDateFormat:@"MM/DD/YYYY hh:mm a"];NSDate *datefor=[dateformat
..
我试图只获取意味着小时、分钟、秒为零的日期.这就是我正在尝试的 延期日期{var onlyDate: 日期?{得到 {让日历 = Calendar.currentvar dateComponents = calender.dateComponents([.year, .month, .day], from: self)dateComponents.timeZone = NSTimeZone.sy
..
我有一个类似 2013-03-05T07:37:26.853 的字符串,我想得到 Output : 2013-03-05 07:37:26.我想要 NSDate 对象中的最终输出.我正在使用下面的函数来转换欲望输出.它返回错误的时间. - (NSDate *) getDateFromCustomString:(NSString *) dateStr{ NSArray *dateStrParts
..
我想获取给定月份的最后一个工作日.我遇到了这个简单的答案,了解如何获得第一个/第二个/...工作日效果很好. 问题是:如何获得给定月份的最后一个工作日?不是每个月都只有4个星期天,那么我是不是要计算这个月的星期天数呢,还是有更优雅的方法呢? 解决方案 我终于想出了以下解决方案.为方便起见,我使用 NSDate-Extensions.dayOfWeek 代表公历中的星期日 (1) 至星
..
我使用以下代码来设置日期对象: NSDate *date = [NSDate 日期];NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];NSDateComponents *components = [gregorian components: NSUIntege
..
我正在为 iPhone 开发一个应用程序,但我坚持到了这一点: 我从一个对象中获取这些数据: {日期 = "2014-08-04 11:21:26 +0000";idChallenger = "-1";索引 = "-1";时间 = "-1";},{日期 = "2015-07-31 14:50:40 +0000";idChallenger = 43;索引 = "-1";时间 = "-1";}
..
由于 NSDateCompoments,我正在使用递增/递减的 NSDate: dateComponents = [[NSDateComponents alloc] init];self.date = [gregorian dateByAddingComponents:dateComponents toDate:[NSDate date] options:0]; ... [dateCompo
..
假设我有以下初始化 NSDateComponents 的代码: NSCalendar *calendar = [NSCalendar currentCalendar];NSDateComponents *components = [[NSDateComponents alloc] init];[组件设置年份:1987];[组件设置月份:3];[组件 setDay:17];[组件设置时间:14];
..
我的问题与下面代码片段中给出的 NSDateComponents 操作的时间配置文件有关. 我有一个方法可以遍历大量 NSDate 对象 部分方法要求我丢弃每个日期的小时、分钟和秒. 为此,我有 3 个步骤: 我从原始日期创建了一个 NSDateComponents 对象. 我将 H:M:S 元素设置为 0 我根据需要将 H:M:S 设置为 0 的新日期对象 问题:
..
我需要获取本周特定日期(星期日)的日期.我使用这个日期来确定是否应该进行每周重置,并且我对上次重置日期是在星期日日期之前进行了一些计算.这原则上已经被多次询问和回答,并且我的解决方案在过去 6 个月内一直有效.但是今天,也就是 2013 年 12 月 29 日,它停止工作了. 目前使用的函数: + (NSDate *) getSundaysDate{NSDate *currentDate
..