Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a false NSDate from string #63

Closed
robyzhou opened this issue Apr 12, 2016 · 2 comments
Closed

Getting a false NSDate from string #63

robyzhou opened this issue Apr 12, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@robyzhou
Copy link

Hi,

I'm using this components to get a NSDate from a string obtained from Facebook API, but I found the NSDate is not right.

I tried the code bellow:

ISO8601DateFormatter* formatter = [[ISO8601DateFormatter alloc] init];
NSDate* date = [formatter dateFromString:@"2014-12-01"];
And I get the date as 2014-11-30 16:00:00 +0000, it's one day before 2014-12-01.

Yes, I'm in China, it looks right if we count the timezone element in.

But, I have tried other components on ISO8601, for example https://github.com/soffes/ISO8601
I tried the code the same as above, and I get the date as 1999-05-01 00:00:00 +0000

I have read the doc, didn't find any clue to get the same result as ISO8601 from this components.

Could you please teach me how to get a date as 2014-11-30 16:00:00 +0000 using this components?

Thanks in advance.

BR,
roby

@robyzhou robyzhou reopened this Apr 12, 2016
@boredzo
Copy link
Owner

boredzo commented Apr 17, 2016

With this change, you'll be able to set formatter.defaultTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"] to have dateFromString: resolve the components in UTC. Then that string returns the date you expected.

If I'm reading you right, @soffes's parser resolved that to 1995? You should file a bug report for that project, I think.

@boredzo boredzo added the bug label Apr 17, 2016
@boredzo boredzo self-assigned this Apr 17, 2016
@boredzo boredzo added this to the 0.8.0 milestone Apr 17, 2016
@robyzhou
Copy link
Author

@boredzo Thank you for your help! And sorry for the typo, it's not 1995, it's 2014. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants