Re: [R] strptime with +03:00 zone designator

2023-11-10 Thread Richard O'Keefe
(1) I hadn't tried to submit a bug report because (a) I wasn't sure
that it was an actual limitation in strptime() and not my ignorance or
stupidity and (b) I didn't actually know how to submit a bug report.
> bug.report(package = "base")
brings up a web page.  Clicking on "File a Bug" takes me to another page,
https://bugs.r-project.org/enter_bug.cgi
which says "
Bugzilla needs a legitimate login and password to continue
" and I don't have a login or a password for this.  The process is
more hassle than I really wanted to go through. Oh well, I'd better do
the thing properly.

(2) The relevant aspect of the ISO 8601 standard has been stable since
1988.  There are two ways to display any time thingy, a basic format
(where NONE of the optional separators are present) and an extended
format (where ALL of the optional separators are present).  There's no
half-and-half form.

On Mon, 6 Nov 2023 at 22:01, Martin Maechler  wrote:
>
> > Richard O'Keefe
> > on Mon, 6 Nov 2023 18:37:34 +1300 writes:
>
> > Thanks to all who replied.  On Mon, 6 Nov 2023 at 18:37,
> > Richard O'Keefe  wrote:
>
> >> OK, so the consensus is (1) One cannot make strptime
> >> accept ISO8601-compliant zone designators (2) The
> >> lubridate package can (3) Or one can hack away with
> >> regex.  Lubridate it is, then.
> >>
> >> But I do regard strptime's inability to process
> >> ISO8601-compliant zone designators as a bug.
>
> Did you try to submit it to R's bugzilla?
>
> It's the first time I hear of this "Feature" of the ISO
> standard, but then I'm not at all a timezone, and even less an
> ISO standard expert.
>
> Best,
> Martin
>
>
> >> On Mon, 6 Nov 2023 at 13:18, jim holtman
> >>  wrote:
> >>
> >>> try using 'lubridate'
> >>>
> >>> > library(lubridate)Attaching package: ‘lubridate’
> >>>
> >>> The following objects are masked from ‘package:base’:
> >>>
> >>> date, intersect, setdiff, union > x <-
> >>> "2017-02-28T13:35:00+03:00"> ymd_hms(x)[1] "2017-02-28
> >>> 10:35:00 UTC"
> >>>
> >>> >
> >>>
> >>>
> >>>
> >>> Thanks
> >>>
> >>> Jim Holtman *Data Munger Guru*
> >>>
> >>>
> >>> *What is the problem that you are trying to solve?Tell
> >>> me what you want to do, not how you want to do it.*
> >>>
> >>>
> >>> On Sun, Nov 5, 2023 at 3:45 PM Richard O'Keefe
> >>>  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@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.
> 
> >>>
>
> >   [[alternative HTML version deleted]]
>
> > __
> > R-help@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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] strptime with +03:00 zone designator

2023-11-06 Thread Joshua Ulrich
On Mon, Nov 6, 2023 at 3:02 AM Martin Maechler
 wrote:
>
> > Richard O'Keefe
> > on Mon, 6 Nov 2023 18:37:34 +1300 writes:
>
> > Thanks to all who replied.  On Mon, 6 Nov 2023 at 18:37,
> > Richard O'Keefe  wrote:
>
> >> OK, so the consensus is (1) One cannot make strptime
> >> accept ISO8601-compliant zone designators (2) The
> >> lubridate package can (3) Or one can hack away with
> >> regex.  Lubridate it is, then.
> >>
> >> But I do regard strptime's inability to process
> >> ISO8601-compliant zone designators as a bug.
>
> Did you try to submit it to R's bugzilla?
>
> It's the first time I hear of this "Feature" of the ISO
> standard, but then I'm not at all a timezone, and even less an
> ISO standard expert.
>
FWIW, the timezone offset format (%z) is handled in
src/main/Rstrptime.h around line 987. There's a comment that only the
RFC 822 form is recognized (+/-HHMM). The fix may be as simple as
ignoring the ':' in the while() loop.

> Best,
> Martin

>
> __
> R-help@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.

__
R-help@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.


Re: [R] strptime with +03:00 zone designator

2023-11-06 Thread Martin Maechler
> Richard O'Keefe 
> on Mon, 6 Nov 2023 18:37:34 +1300 writes:

> Thanks to all who replied.  On Mon, 6 Nov 2023 at 18:37,
> Richard O'Keefe  wrote:

>> OK, so the consensus is (1) One cannot make strptime
>> accept ISO8601-compliant zone designators (2) The
>> lubridate package can (3) Or one can hack away with
>> regex.  Lubridate it is, then.
>> 
>> But I do regard strptime's inability to process
>> ISO8601-compliant zone designators as a bug.

Did you try to submit it to R's bugzilla?

It's the first time I hear of this "Feature" of the ISO
standard, but then I'm not at all a timezone, and even less an
ISO standard expert.

Best,
Martin


>> On Mon, 6 Nov 2023 at 13:18, jim holtman
>>  wrote:
>> 
>>> try using 'lubridate'
>>> 
>>> > library(lubridate)Attaching package: ‘lubridate’
>>> 
>>> The following objects are masked from ‘package:base’:
>>> 
>>> date, intersect, setdiff, union > x <-
>>> "2017-02-28T13:35:00+03:00"> ymd_hms(x)[1] "2017-02-28
>>> 10:35:00 UTC"
>>> 
>>> >
>>> 
>>> 
>>> 
>>> Thanks
>>> 
>>> Jim Holtman *Data Munger Guru*
>>> 
>>> 
>>> *What is the problem that you are trying to solve?Tell
>>> me what you want to do, not how you want to do it.*
>>> 
>>> 
>>> On Sun, Nov 5, 2023 at 3:45 PM Richard O'Keefe
>>>  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@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.
 
>>> 

>   [[alternative HTML version deleted]]

> __
> R-help@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.

__
R-help@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.


Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread Richard O'Keefe
Thanks to all who replied.

On Mon, 6 Nov 2023 at 18:37, Richard O'Keefe  wrote:

> OK, so the consensus is
> (1) One cannot make strptime accept ISO8601-compliant zone designators
> (2) The lubridate package can
> (3) Or one can hack away with regex.
> Lubridate it is, then.
>
> But I do regard strptime's inability to process ISO8601-compliant zone
> designators as a bug.
>
>
> On Mon, 6 Nov 2023 at 13:18, jim holtman  wrote:
>
>> try using 'lubridate'
>>
>> > library(lubridate)Attaching package: ‘lubridate’
>>
>> The following objects are masked from ‘package:base’:
>>
>> date, intersect, setdiff, union
>> > x <- "2017-02-28T13:35:00+03:00"> ymd_hms(x)[1] "2017-02-28 10:35:00 UTC"
>>
>> >
>>
>>
>>
>> Thanks
>>
>> Jim Holtman
>> *Data Munger Guru*
>>
>>
>> *What is the problem that you are trying to solve?Tell me what you want
>> to do, not how you want to do it.*
>>
>>
>> On Sun, Nov 5, 2023 at 3:45 PM Richard O'Keefe  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@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.
>>>
>>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread Richard O'Keefe
OK, so the consensus is
(1) One cannot make strptime accept ISO8601-compliant zone designators
(2) The lubridate package can
(3) Or one can hack away with regex.
Lubridate it is, then.

But I do regard strptime's inability to process ISO8601-compliant zone
designators as a bug.


On Mon, 6 Nov 2023 at 13:18, jim holtman  wrote:

> try using 'lubridate'
>
> > library(lubridate)Attaching package: ‘lubridate’
>
> The following objects are masked from ‘package:base’:
>
> date, intersect, setdiff, union
> > x <- "2017-02-28T13:35:00+03:00"> ymd_hms(x)[1] "2017-02-28 10:35:00 UTC"
>
> >
>
>
>
> Thanks
>
> Jim Holtman
> *Data Munger Guru*
>
>
> *What is the problem that you are trying to solve?Tell me what you want to
> do, not how you want to do it.*
>
>
> On Sun, Nov 5, 2023 at 3:45 PM Richard O'Keefe  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@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.
>>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread jim holtman
try using 'lubridate'

> library(lubridate)Attaching package: ‘lubridate’

The following objects are masked from ‘package:base’:

date, intersect, setdiff, union
> x <- "2017-02-28T13:35:00+03:00"> ymd_hms(x)[1] "2017-02-28 10:35:00 UTC"

>



Thanks

Jim Holtman
*Data Munger Guru*


*What is the problem that you are trying to solve?Tell me what you want to
do, not how you want to do it.*


On Sun, Nov 5, 2023 at 3:45 PM Richard O'Keefe  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@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.
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread Jeff Newmiller via R-help
I usually just use a regex to strip the colon.

On November 5, 2023 3:45:01 PM PST, Richard O'Keefe  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@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.

__
R-help@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.


Re: [R] strptime with +03:00 zone designator

2023-11-05 Thread Roy Mendelssohn - NOAA Federal via R-help
what if you try lubridate::as_datetime('2017-02-28T13:35:00+03:00’)

-Roy


> On Nov 5, 2023, at 3:45 PM, Richard O'Keefe  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@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.

__
R-help@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.


[R] strptime with +03:00 zone designator

2023-11-05 Thread Richard O'Keefe
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@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.