[R] Difference between times

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Apr 20 11:16:12 CEST 2014


On 20/04/2014 08:50, Prof Brian Ripley wrote:
> On 18/04/2014 21:46, David Winsemius wrote:
>>
>> 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:

You can always use the command-line or OlsonNames() in R.
>>
>>> 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?
>
> No, as the underlying POSIX function does not report this.  We could
> perhaps do this on platforms which use --with-internal-tzcode but not
> e.g. on Linux.

In fact we already do: R 3.1.0 on a Mac shows

 > as.POSIXct("2014-04-18 09.00", format="%Y-%m-%d %H.%M", tz = 
"Americas/New_York")
[1] "2014-04-18 09:00:00 GMT"
Warning messages:
1: In strptime(x, format, tz = tz) : unknown timezone 'Americas/New_York'
2: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :
   unknown timezone 'Americas/New_York'
3: In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'Americas/New_York'


-- 
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




More information about the R-help mailing list