[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] Date Parsing Problems.
From: |
Ralph Corderoy |
Subject: |
Re: [Nmh-workers] Date Parsing Problems. |
Date: |
Sun, 23 Apr 2017 12:45:06 +0100 |
Hi again,
> So are all ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST's effects cancelled
> out? Setting it to zero passes all tests and suggests it can be
> deleted along with the code it wraps?
Changing ADJUST_NUMERIC_ONLY_TZ_OFFSETS_WRT_DST from 1 to 0 passes all
tests because it's tested with #ifdef! :-)
To test if it was doing anything, I deleted it locally, and all the code
it wraps, and the ripples, e.g. a function's unused parameter. One test
then fails: test/mhical/test-mhical. I'm not sure the test's correct?
It takes
BEGIN:VCALENDAR
VERSION:2.0
PRODID:test-mhical
BEGIN:VTIMEZONE
TZID:Eastern Standard Time
BEGIN:STANDARD
DTSTART:16010101T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20150101T000000Z
DTSTART;TZID=Eastern Standard Time:20140309T015959
DTEND;TZID=Eastern Standard Time:20140309T023000
Summary: EST to EDT
END:VEVENT
END:VCALENDAR
and wants this output
Summary: EST to EDT
At: Sun, 09 Mar 2014 01:59 -0500
To: Sun, 09 Mar 2014 03:30
but the time of the `To' line comes out wrong now.
To: Sun, 09 Mar 2014 04:30
Firstly, is that a valid VCALENDAR? Is the event 31 minutes long? Does
DTEND;TZID=Eastern Standard Time:20140309T023000
mean that 02:30:00 time is EST? Only that's in the hour that's jumped
over so date(1) isn't happy it exists, but perhaps VCALENDAR defines
that's OK. Here's DTSTART.
$ fmt='+%Y-%m-%d %T %z %Z'
$
$ TZ=EST5EDT /bin/date -d '2014-03-09T01:59:00 EST' "$fmt"
2014-03-09 01:59:00 -0500 EST
And then the time 31 minutes later.
$ TZ=EST5EDT /bin/date -d '2014-03-09T01:59:00 EST + 31 minutes' "$fmt"
2014-03-09 03:30:00 -0400 EDT
That matches the expect, zoneless, result.
The lexer sets the zone to -05:00 for both EST and EDT, but sets the DST
flag for the latter.
{nl}("est"|"EST") SETZONE(-500);
{nl}("edt"|"EDT") SETDST(); SETZONE(-500);
Would it be better to ditch DST from the calculations, and make EDT -400
above? Then it wouldn't need adjusting again on formatting?
The only other use for the DST flag seems to be mh-format(5)'s %(szone)
function.
Function Argument Return Description
szone date integer timezone explicit?
(1=explicit,0=implicit,-1=unknown)
I don't think 0, implicit, is ever returned.
$ try() { uip/fmttest -date -format '%(putnum(szone{text}))' "$@"; }
$
$ try 'Sun, 23 Apr 2017 12:00:00 +0100'
1
$ try 'Sun, 23 Apr 2017 12:00:00 EST'
1
$ try 'Sun, 23 Apr 2017 12:00:00 foo'
-1
$ try 'Sun, 23 Apr 2017 12:00:00'
-1
There's only one bit in the masks.
#define TW_SZONE 0x0004 /* how timezone was determined */
#define TW_SZNIL 0x0000 /* not given */
#define TW_SZEXP 0x0004 /* explicitly given */
--
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy