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

Days of the week are off by one when timezone set to Beirut(+3:00) #269

Open
WaelSleiman opened this issue Apr 1, 2016 · 17 comments
Open

Comments

@WaelSleiman
Copy link

To whom it may concern,
The issue is in the month of april. All the april days start one day after the last day of march.
Example: April 1, 2016 is being shown as Saturday while March 31, 2016 is a Thurday in the com.squareup.timessquare.CalendarPickerView.
This error is being repeated over the year.

Thank you for your time.

@edenman
Copy link
Collaborator

edenman commented Apr 1, 2016

Screenshot? I have no idea what you're saying.

@WaelSleiman
Copy link
Author

Sorry for the delay.
screenshot

@edenman
Copy link
Collaborator

edenman commented Apr 4, 2016

That is very strange. Works fine for me:
screen shot 2016-04-04 at 11 42 51 am

Can you post the code you're using to initialize the view? Also, what locale are you in?

@WaelSleiman
Copy link
Author

After further testing on other devices, I found out that this bug is not appearing on my Nexus 6
while it is still happening on my HTC one M9 and Samsung J5.
The local being used by all three is GMT +03:00 Eastern European Summer Time
The native date is working as it should.
All three are using the same project build.

As for the initialization of the calendar,
private Date minDate;
private Date maxDate;
CalendarPickerView calendarView;

minDate = Calendar.getInstance();
minDate.setTime(date);
minDate.add(Calendar.DAY_OF_YEAR, -1);

maxDate = Calendar.getInstance();
maxDate.setTime(date);
maxDate.add(Calendar.YEAR, 1);

date = minDate.getTime();

calendarView.init(minDate.getTime(), maxDate.getTime()).inMode(CalendarPickerView.SelectionMode.SINGLE).withSelectedDate(date);

@edenman
Copy link
Collaborator

edenman commented Apr 5, 2016

Well that's perplexing. I can't reproduce the issue on any of the phones I have at my disposal so I'm not going to be able to help. Try running the sample app on one of your phones to see if it has the same issue? I'd love a PR if you figure out where the bug is.

@WaelSleiman
Copy link
Author

I checked using the sample app and received the same result as my app.
Thank you for your time

@edenman
Copy link
Collaborator

edenman commented Apr 6, 2016

Hrm. If you see the same issue in the sample app, that definitely sounds like a bug...maybe hook up the debugger and see if you can see why it's selecting the wrong date?

@WaelSleiman WaelSleiman reopened this Apr 28, 2016
@WaelSleiman
Copy link
Author

Hello again,
So i was able to find the cause of this bug.
Apparently i was mistaken in my previous statement when i told you that this bug does not appear on my Nexus device. I was able to reproduce it by changing locales.
To reproduce it, change the local to Beirut(+3:00). I don't know if it exist in other locales.
Here is a video to view the bug in action:
https://www.youtube.com/watch?v=0r4GTM98Ndo&feature=youtu.be

@edenman edenman changed the title Bug in the month of April Days of the week are off by one when timezone set to Beirut(+3:00) Apr 28, 2016
@edenman
Copy link
Collaborator

edenman commented Apr 28, 2016

Innnnteresting. I don't have time to look at this right now, but definitely curious to see what's busted here. PR welcome if you figure it out!

@cnordvik
Copy link

We have a user with the same bug (from Libanon). Notice that April 1 is both on Saturday and Sunday here. His feedback was:

April 1 starts on Sunday instead of Saturday so whenever we click on Wednesday 4, for example, it redirects us to Tuesday 4

pasted image at 2017_03_29 10_23

@Namiii
Copy link

Namiii commented Aug 21, 2017

We have a handful of reports of this happening as well, have there been any developments on this issue or nothing yet?

@edenman
Copy link
Collaborator

edenman commented Aug 22, 2017

Nope. I haven't been able to repro. PRs welcome if you figure it out!

@akul1994
Copy link

akul1994 commented Jan 12, 2018

happening with me as well. Only on the samsung galaxy s6 edge though for IST+5.30 timezone. any updates?

@ashish21
Copy link

Having the same issue for IST+5.30 timezone as well on some devices. @edenman any insight??

@jontelang
Copy link

I cannot provide a proper solution, but something of a workaround. Our app uses a fixed header where the order of the weekdays are hardcoded. We had the same issue, and our solution was to force the calendar to use a US locale. This fixed it on all our devices that had the issue.

It's not an exact solution, but it might help someone out.

We have not yet tried to reproduce the issue with the default 'weekday header', but we might do that later.

The code in our app looks like this:

calendar.init(cal.getTime(), mCalendar.getTime(), new Locale(Locale.getDefault().getLanguage(), Locale.US.getCountry()))

Note that I am not the Android developer, so the solution is somewhat paraphrased.

@kidsh3148
Copy link

@jontelang Yes, your solution will definitely help us for showing the dates on a proper day, but then when we are clicking on the particular date it will return the date before one day for the first time.

calendar.setOnDateSelectedListener(new CalendarPickerView.OnDateSelectedListener() { @Override public void onDateSelected(final Date date) {

If I am clicking on the 20th Jan 2019 then it will return me Sun Jan 19 00:00:00 GMT-01:00 2019.

Did you faced something like this!!??

@jontelang
Copy link

@kidsh3148 That's a good question. I only assume we did not have this issue, as it passed QA. But I don't have access to double check it at the moment.

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

8 participants