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

Isoweek() problem in European timezones #311

Closed
johandicap opened this issue Apr 13, 2015 · 2 comments

Comments

@johandicap
Copy link

commented Apr 13, 2015

Hi, it appears that there is a problem with the isoweek() function for European timezones.

For instance tomorrow, April 14th 2015, it is Tuesday of week 16 here in Copenhagen, Denmark, but isoweek says it is week 15:

> ymd_hms("2015-04-14 16:45:00", tz="Europe/Copenhagen")
[1] "2015-04-14 16:45:00 CEST"
> isoweek(ymd_hms("2015-04-14 16:45:00", tz="Europe/Copenhagen"))
[1] 15  # Wrong

For UTC, it correctly returns week 16:

> ymd_hms("2015-04-14 16:45:00", tz="UTC")
[1] "2015-04-14 16:45:00 UTC"
> isoweek(ymd_hms("2015-04-14 16:45:00", tz="UTC"))
[1] 16  # Correct

Note that CEST (Central European Summer Time) is UTC + 2, so this should not influence the week number on a Tuesday afternoon.

It does not work for CET either:

> ymd_hms("2015-04-14 16:45:00", tz="CET")
[1] "2015-04-14 16:45:00 CEST"
> isoweek(ymd_hms("2015-04-14 16:45:00", tz="CET"))
[1] 15  # Wrong

So this appears to be a bug in lubridate or in the general handling of timezones.

(I am using lubridate 1.3.3 with 32-bit R 3.1.3 in RStudio 0.98.1103 on 64-bit Windows 7 SP1.)

Best regards,
Johan

ps: Finding the isoweek() function in the first place took me actually quite a while, since I did not see it mentioned when I skimmed the week() documentation via ?week. I suggest adding a "See also" section or an example mentioning isoweek() to the week() documentation to highlight its existence.

@vspinu

This comment has been minimized.

Copy link
Member

commented Apr 16, 2015

Note that CEST (Central European Summer Time) is UTC + 2, so this should not influence the week number on a Tuesday afternoon.

Yep. It's a bug. Thanks.

ps: Finding the isoweek() function in the first place took me actually quite a while, since I did not see it mentioned when I skimmed the week() documentation via ?week. I suggest adding a "See also" section or an example mentioning isoweek() to the week() documentation to highlight its existence.

Indeed. The docs should be refactored and isoweek should be at least mentioned in the week docs.

@vspinu vspinu added the bug label Apr 16, 2015

@vspinu vspinu closed this in fc3edd8 Apr 23, 2015

@vspinu

This comment has been minimized.

Copy link
Member

commented Apr 23, 2015

The problem was the small difference introduced by daylight saving time. To avoid this issue the isoweek is computed now exclusively in UTC.

It turns out that the documentation for week and isoweek is is now the same page. I forgot that fixed that some time ago. You should probably upgrade to the github version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.