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

DateTime fails #120

okumuralab opened this Issue Apr 12, 2015 · 4 comments


None yet
3 participants

okumuralab commented Apr 12, 2015

x = read_csv("DateTime\n2013-02-10 12:34:56")
fails. I have to supply col_types:
x = read_csv("DateTime\n2013-02-10 12:34:56", col_types="T")

x = read_csv("DateTime\n2013-02-10 12:34:56 JST")
doesn't fail, but the result is a character string, not POSIXct.


This comment has been minimized.

okumuralab commented Apr 12, 2015

parse_datetime("2015-04-12 00:00:00")
[1] "2015-04-12 UTC"
Oops, I meant JST (Japan Standard Time)
parse_datetime("2015-04-12 00:00:00", tz="JST")
[1] "2015-04-12 GMT"
In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'JST'
Oops, is it Tokyo or Japan?
parse_datetime("2015-04-12 00:00:00", tz="Japan")
[1] "2015-04-11 23:00:00 JST"
Off-by-one hour error!


This comment has been minimized.


hadley commented Apr 13, 2015

2013-02-10 12:34:56 JST isn't a ISO8601 date time because it has the time zone as a string. I'll look into the off-by-one error.


This comment has been minimized.


asnr commented Jul 20, 2015

The off-by-one error appears to be daylight savings related:

# In daylight savings
parse_datetime("2015-04-04 00:00:00", tz="Australia/Melbourne")
#> [1] "2015-04-04 AEDT"

# Not in daylight savings (Japan doesn't do daylight savings)
parse_datetime("2015-04-04 00:00:00", tz="Japan")
#> [1] "2015-04-03 23:00:00 JST"

# Not in daylight savings
parse_datetime("2015-04-06 00:00:00", tz="Australia/Melbourne")
#> [1] "2015-04-05 23:00:00 AEST"

# Not in daylight savings (Japan doesn't do daylight savings)
parse_datetime("2015-04-06 00:00:00", tz="Japan")
#> [1] "2015-04-05 23:00:00 JST"

I did some debugging of the DateTime::localtime function and it seems the tm_isdst member of the struct tm object is unassigned and getting filled with junk that just so happens to always be a positive integer, forcing mktime() to parse the string as a daylight savings time.


This comment has been minimized.


hadley commented Jul 20, 2015

@Andres-S oops. Would you mind making a couple of formal test cases? It should be an easy fix (tm.tm_isdst = 0;).

@hadley hadley closed this in 7c8b65e Jul 21, 2015

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.