[R] Difference between times
David Winsemius
dwinsemius at comcast.net
Fri Apr 18 22:46:56 CEST 2014
On Apr 18, 2014, at 12:59 PM, Prof Brian Ripley wrote:
> On 18/04/2014 19:46, Rui Barradas wrote:
>> Hello,
>>
>> The reason why is that you've misspelled CET (not CEST)
>
> Neither CET nor CEST are portable time-zone names. We have not been given the 'at a minimum' information required by the posting guide, so please read ?Sys.timezone on your system.
Dear Prof;
Thanks for the impetus to yet again read that page. Despite frequently reading help pages and in particular reading that one many times, I still was not getting the 'tz' arguments correct on a Mac. I do now see that I was spelling my TZ incorrectly (as "Americas/Los_Angeles" rather than "America/Los_Angeles".
Fellow Mac users may face a problem when using the Finder unless they set it up to display hidden ('dot') files. The /usr/ folder is "greyed out" but it still does open. If I restore my Finder defaults to not show system files and folders, I no longer see that directory and would not have been able to resolve my spelling error on my own:
> dt2 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = "America/New_York")
> dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = "America/Los_Angeles")
> dt1-dt2
Time difference of 3 hours
I don't suppose a warning could be issued by the as.POSIXct code when a "tz" argument is not found in the database to let people know that 'UTC' will be the default?
--
David.
>
>
>>
>> > dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz =
>> "CEST")
>> Warning messages:
>> 1: In strptime(x, format, tz = tz) : unknown timezone 'CEST'
>> 2: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :
>> unknown timezone 'CEST'
>> > dt2 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz =
>> "GMT")
>> > dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz =
>> "CET")
>> > dt1-dt2
>> Time difference of -2 hours
>>
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>> Em 18-04-2014 17:13, Nicola Sturaro Sommacal escreveu:
>>> Hi.
>>>
>>> I am new to POSIX and I'd like to understand the reason of this
>>> difference.
>>>
>>> dt1 = as.POSIXct("2014-03-29 09.00", format="%Y-%m-%d %H.%M")
>>> dt2 = as.POSIXct("2014-03-30 09.00", format="%Y-%m-%d %H.%M")
>>> dt2-dt1
>>>
>>>> dt1[1] "2014-03-29 09:00:00 CET"> dt2[1] "2014-03-30 09:00:00 CEST">
>>>> dt2-dt1
>>>
>>> Time difference of 23 hours
>>>
>>> This is right, because on Mar 31 at 2 PM we jump directly to 3PM, DST.
>>>
>>> On the contrary, I don't understand the following:
>>>
>>> dt1 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz =
>>> "CEST")
>>> dt2 = as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = "GMT")
>>>
>>>> dt1[1] "2014-04-18 09:00:00 CEST"> dt2[1] "2014-04-18 09:00:00 GMT">
>>>> dt1-dt2Time difference of 0 secs
>>>
>>>
>>> I should expected a time difference of 2 hours, as CEST is GMT+2.
>>>
>>> Anyone can help me?
>>>
>>> Thank you,
>>> Nicola
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list