[R] strptime with +03:00 zone designator

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon Nov 6 01:07:38 CET 2023


I usually just use a regex to strip the colon.

On November 5, 2023 3:45:01 PM PST, Richard O'Keefe <raoknz using gmail.com> wrote:
>I have some data that includes timestamps like this:
>2017-02-28T13:35:00+03:00
>The documentation for strptime says that %z expects
>an offset like 0300.  I don't see any way in the documentation
>to get it to accept +hh:mm with a colon separator, and
>everything I tried gave me NA as the answer.
>
>Section 4.2.5.1 of ISO 8601:2004(E) allows both the
>absence of colons in +hh[mm] (basic format) and the
>presence of colons in +hh:mm (extended format).
>Again in section 4.2.5.2 where a zone offset is combined
>with a time of day: if you have hh:mm:ss you are using
>extended format and the offset MUST have a colon; if
>you have hhmmss you are using basic format and the
>offset MUST NOT have a colon.  And again in section
>4.3.2 (complete representations of date and time of day).
>If you use hyphens and colons in the date and time part
>you MUST have a colon in the zone designator.
>
>So I am dealing with timestamps in strict ISO 8601
>complete extended representation, and it is rather
>frustrating that strptime doesn't deal with it simply.
>
>The simplest thing would be for R's own version of
>strptime to allow an optional colon between the hour
>digits and the minute digits of a zone designator.
>
>I'm about to clone the data source and edit it to
>remove the colons, but is there something obvious
>I am missing?
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

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



More information about the R-help mailing list