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

DateTime fails #120

Closed
okumuralab opened this issue Apr 12, 2015 · 4 comments
Closed

DateTime fails #120

okumuralab opened this issue Apr 12, 2015 · 4 comments

Comments

@okumuralab
Copy link

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.

@okumuralab
Copy link
Author

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!

@hadley
Copy link
Member

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.

@asnr
Copy link
Contributor

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.

@hadley
Copy link
Member

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 as completed 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.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants