[R] [Tagged] Re: Question about Date Object and time zones

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Wed Sep 25 21:35:51 CEST 2024


... or a timezone string.

... or do what I usually do and use POSIXct for dates as well as times, self-managing use of midnight local time for "dates".

On September 25, 2024 5:40:37 AM EDT, Ivan Krylov via R-help <r-help using r-project.org> wrote:
>24 сентября 2024 г. 17:10:13 GMT+03:00, Luca Brinkmann via R-help <r-help using r-project.org> пишет:
>> My current
>> understanding is, that a Date object does only save the days from the
>> origin and no more information about timezones or other information
>> (please correct me if I am wrong).
>
>You are correct.
>
>
>> the date object is displayed in my RStudio environment as "2024-11-11
>> UTC".
>
>This looks like a result of as.POSIXlt(<Date object>).
>
>> In contrast, getting the timezone information with base::format will
>> yield the timezone information
>> > base::format(d, format="%Z")
>> [1] "UTC"
>
>That's an implementation detail: the format() method for Date objects conjures a temporary POSIXlt object and formats the result, and POSIXlt objects can contain time zone information.
>
>> Is there any way to add timezone information to an Date
>> object (other than UTC) and keeping it a Date object?
>
>Not with a plain 'Date'. What should a date in a timezone mean? Start of day? End of day? The whole 24-hour interval (except when it lasts 23 or 25 hours due to DST)?
>
>Perhaps you could store one (or two for an interval) POSIXt object(s) if you need timezone information for your dates.
>

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list