nsdate

Converting ex. 2009-12-31T00:00:00.0000000-05:00 format to NSDate

做~自己de王妃 提交于 2019-12-25 03:12:45
问题 I am working with getting data from webservice in iPhone app and getting a date in format 2009-12-31T00:00:00.0000000-05:00.. How can I convert this to NSDate.. Please help.... 回答1: The problem with this format is that the -05:00 format is not supported by NSDateFormatter date formats. Unicode date format patterns says it supports -0500 though. You may have to manually strip the colon out of the timezone and then parse it using the format yyyy-MM-dd'T'HH:mm:ss.0000000ZZZ (or maybe yyyy-MM-dd

Daily UILocalNotification firing more than once

落爺英雄遲暮 提交于 2019-12-25 02:42:50
问题 Hello i am facing a weird kind problem. Actually i want to schedule a daily notification (only once a day) at 8:00 AM. Below is my code for scheduling daily notification. NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"HH:mm"]; NSDate *date = [[NSDate alloc] init]; date = [formatter dateFromString:@"08:00"]; UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = date; localNotification.timeZone=

Core Data under Japanese Calendar incorrectly comparing dates

蓝咒 提交于 2019-12-25 02:24:22
问题 So I seem to be getting burned by the iPhone's calendar support again. I've come across an issue with the way core data compares dates. Core data appears to be storing dates using the Gregorian calendar as they come out in a 20XX-MM-dd format. But when I build an NSPredicate this way [nsRequest setPredicate:[NSPredicate predicateWithFormat:@"publish <= %@ AND expires >= %@", [NSDate date], [NSDate date]]] if the user's device isn't set to a Gregorian calendar then no items will appear, as

NSDate as argument in customMethod

不想你离开。 提交于 2019-12-25 01:59:45
问题 I've defined my custom method ( -(void)loadXML {} ) into my appDelegate. Now I'd like to use it in severals viewControllers; Right now I'm using local NSDate objects. NSDate *todayDate = [NSDate date]; NSString *XMLUrl = @"http://localhost/MyApp/GetXML?&aDate="; NSString *urlString = [NSString stringWithFormat:@"%@%@", XMLUrl, todayDate]; tbxml = [[TBXML alloc] initWithURL:[NSURL URLWithString:urlString]]; instead of 'todayDate' I'd like to have 'selectedDate'; also how I add a bool to my

How to sort the Array that contains date in strings in ascending order

霸气de小男生 提交于 2019-12-25 01:56:00
问题 I have array of dictionaries ,In every dictionary contains one date parameter . The array of date parameters(contains in dictionaries) as follow: [@"16-1-2015 7:00PM",@"15-1-2014 11:30AM",@"14-1-2014 7:00PM", @"15-1-2015 6:30AM ".@"16-1-2015 8:30PM"] I need output like : [@"16-1-2015 8:30PM",@"16-1-2015 7:00PM",@"15-1-2015 6:30AM ", @"15-1-2014 11:30AM",@"14-1-2014 7:00PM"]; 回答1: You could try this: NSArray *dateStringArray = @[ @"16-1-2015 7:00PM", @"15-1-2014 11:30AM", @"14-1-2014 7:00PM",

Is this method going to always give me 12:00:00 of the current day in ios?

对着背影说爱祢 提交于 2019-12-25 01:27:46
问题 Yes, this is similar to NSDate beginning of day and end of day, but that topic does not discuss whether it works for all situations which is what I am asking here. That question dealt with not getting back the correct value because they forgot NSDayCalendarUnit. This question is dealing with the accuracy of the value which as it turns out is not going to work with DST as I had suspected. In several parts of my app, I have the need to specify a time of day without caring about the actual day,

Get the last weekday of a month

混江龙づ霸主 提交于 2019-12-25 00:29:06
问题 I want to get the last weekday of a given month. I've come across this simple answer on how to get the 1st/2nd/... weekday which works well. The question is: How to get the last weekday of a given month? Not every month has only 4 Sundays, so do I have to count the number of Sundays of the month, or is there a more elegant way to do this? 回答1: Had the same need recently, and the best I could come up with is the following, which is meant to be run every day to check if the current day is the

How to get the day of week from a given number

我们两清 提交于 2019-12-24 18:05:11
问题 I want to have the day of week name for a given number, here is the pseudo-code : getDayStringForInt:0 = sunday getDayStringForInt:1 = monday getDayStringForInt:2 = tuesday getDayStringForInt:3 = wenesday getDayStringForInt:4 = thursday getDayStringForInt:5 = friday getDayStringForInt:6 = saturday I have tried with the follow code, but some thing is not working ... - (void) setPeriodicityDayOfWeek:(NSNumber *)dayOfWeek{ gregorian = [[NSCalendar alloc] initWithCalendarIdentifier

Swift - using timers/system clock/background threads to do something in my application every hour

坚强是说给别人听的谎言 提交于 2019-12-24 17:43:26
问题 I'm using: var alarm = NSUserNotification() var currentTime = NSDate() alarmTime = currentTime.dateByAddingTimeInterval(60) alarm.deliveryDate = alarmTime NSUserNotificationCenter.defaultUserNotificationCenter().scheduleNotification(alarm) To get a notification that will fire an hour from the current time, the problem is I want the app to automatically set up another alarm after the first one finishes. NSTimer doesn't seem like it will work because once the app goes to the background it kills

NSDate, timezones and Unix timestamp confusion

和自甴很熟 提交于 2019-12-24 14:21:07
问题 I took over the project of some programmers who unfortunately left a lot of stuff unclear in the code. Basically we have stored some flight events in our database with a departure and arrival time. It the database (as far as we can tell) everything is stored in UTC (as it should) and in the iOS app they use some Realm objects as database model. I basically want to look for all flights in a 24 hour period, corresponding to the 24 hour day of the user's device. - (NSDate *