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 previous date in method didSelect date #531

Closed
raghvendra opened this issue Dec 26, 2016 · 6 comments
Closed

Getting previous date in method didSelect date #531

raghvendra opened this issue Dec 26, 2016 · 6 comments

Comments

@raghvendra
Copy link

Hello,

I have upgraded the library to the latest changes, and when I print the date which user has selected it is showing previous day.
For example when I select Dec 26, the date that it prints is 2016-12-25 18:30:00 +0000

Earlier it used to work correctly.
May I know why it is happening the way it is?

Thanks!

@WenchaoD
Copy link
Owner

Use NSDateFormatter to convert your date to string, then print the string instead.

@raghvendra
Copy link
Author

raghvendra commented Dec 30, 2016

Hi @WenchaoD , thank you for your reply.

Yes, I can use NSFormatter and do that.

But, I have my data structure based on Date or date.timeIntervalFrom1970
and when user selects a particular date - I want to query my data based on date object or timeIntervalFrom1970 value and do something.
My data is not like String : String, it is more like Date : String or Int : String

With NSDateFormatter - I have to format it twice once from date to string and then again string to date.

Hence, I was asking why the method didSelect returns a different date?
(when you print that date you can see it)
Earlier it used to work correctly.

Is this because of a recent change that I can see or we can provide a customization point?

Thank you!

@WenchaoD
Copy link
Owner

@raghvendra I still don't get what does returns a different date means. Here is the screen shot of the example project.
image
image

@raghvendra
Copy link
Author

raghvendra commented Dec 30, 2016

@WenchaoD , Thank you for your reply.

ok.
I am attaching the screenshot of the Example Code with the print statements, that will make things clear.

If I use NSFormatter - I get the date as Dec 28, but when I print that date object it has some different value.

screen shot 2016-12-30 at 8 28 21 am

@raghvendra
Copy link
Author

Ok, I figured out what was the issue that caused it.

The commit with sha ** d3a4531**, changed earlier implementation. The commit description says that - "Local timezone is better"

@sriramselvank
Copy link

How to solve this issue. I didn't get the point.

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

No branches or pull requests

3 participants