Let us start off with two interesting points in time:
Calendar.Second(1067126400);
(1) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
Calendar.Second(1067126400+3600);
(2) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
I'd like to be able to parse a string reprensetation of these into those same objects, as in (reality bent slightly to desired results):
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CEST");
(3) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CET");
(4) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
but the daylight saviness of the zone info isn't taken care of. I have tried to track the internal workings of Calendar to do something about it, but it gets scary quickly. I was kind of hoping for some help. :-)
Oops, those were even more bent than desired. :-) The preferred output is of course:
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CEST");
(3) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CET");
(4) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
/ Johan Sundström, Lysator
Previous text:
2003-10-15 19:42: Subject: Timezones
Let us start off with two interesting points in time:
Calendar.Second(1067126400);
(1) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
Calendar.Second(1067126400+3600);
(2) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
I'd like to be able to parse a string reprensetation of these into those same objects, as in (reality bent slightly to desired results):
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CEST");
(3) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CET");
(4) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
but the daylight saviness of the zone info isn't taken care of. I have tried to track the internal workings of Calendar to do something about it, but it gets scary quickly. I was kind of hoping for some help. :-)
/ Johan Sundström, Lysator
I'm not sure how you would do that. Parse the time with the timezone and see if there is a dst/zone shift nearby and add/remove the change and see if the name matches better, maybe?
/ Mirar
Previous text:
2003-10-15 19:42: Subject: Timezones
Let us start off with two interesting points in time:
Calendar.Second(1067126400);
(1) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
Calendar.Second(1067126400+3600);
(2) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
I'd like to be able to parse a string reprensetation of these into those same objects, as in (reality bent slightly to desired results):
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CEST");
(3) Result: Second(Sun 26 Oct 2003 2:00:00 CET)
Calendar.parse("%y-%M-%D %h:%m:%s %z", "2003-10-26 02:00:00 CET");
(4) Result: Second(Sun 26 Oct 2003 2:00:00 CEST)
but the daylight saviness of the zone info isn't taken care of. I have tried to track the internal workings of Calendar to do something about it, but it gets scary quickly. I was kind of hoping for some help. :-)
/ Johan Sundström, Lysator
No, as the additional comment shows we just want "CET" to be parsed as CET and "CEST" as CEST. Currently the Timezone-complex refuses to understand DST.
Calendar.ISO.dwim_time("2001-01-01 01:01:01");
(1) Result: Second(Mon 1 Jan 2001 1:01:01 CET)
_->set_timezone("CEST");
No timezone "CEST" /home/nilsson/Pike/7.5/lib/modules/Calendar.pmod/Ruleset.pike:39: Calendar.Ruleset()->set_timezone(0) /home/nilsson/Pike/7.5/lib/modules/Calendar.pmod/TimeRanges.pmod:912: Second(Mon 1 Jan 2001 1:01:01 CET)->set_timezone("CEST")
/ Martin Nilsson (saturator)
Previous text:
2003-10-15 20:04: Subject: Timezones
I'm not sure how you would do that. Parse the time with the timezone and see if there is a dst/zone shift nearby and add/remove the change and see if the name matches better, maybe?
/ Mirar
The way I understand the Calendar Timezone design, that would be a nop (CEST and CET being synonyms for central european time); it's in the step before where the TimeRange gets its offset to the epoch where that something needs fixing.
/ Johan Sundström, Lysator
Previous text:
2003-10-15 21:20: Subject: Timezones
No, as the additional comment shows we just want "CET" to be parsed as CET and "CEST" as CEST. Currently the Timezone-complex refuses to understand DST.
Calendar.ISO.dwim_time("2001-01-01 01:01:01");
(1) Result: Second(Mon 1 Jan 2001 1:01:01 CET)
_->set_timezone("CEST");
No timezone "CEST" /home/nilsson/Pike/7.5/lib/modules/Calendar.pmod/Ruleset.pike:39: Calendar.Ruleset()->set_timezone(0) /home/nilsson/Pike/7.5/lib/modules/Calendar.pmod/TimeRanges.pmod:912: Second(Mon 1 Jan 2001 1:01:01 CET)->set_timezone("CEST")
/ Martin Nilsson (saturator)
Ok, another example:
Calendar.ISO.dwim_time("2001-07-01 01:01:01");
(1) Result: Second(Sun 1 Jul 2001 1:01:01 CEST)
_->set_timezone("MEST");
No timezone "MEST" /usr/local/pike/7.5.9/lib/modules/Calendar.pmod/Ruleset.pike:38: Calendar.Ruleset()->set_timezone(0) /usr/local/pike/7.5.9/lib/modules/Calendar.pmod/TimeRanges.pmod:912: Second(Sun 1 Jul 2001 1:01:01 CEST)->set_timezone("MEST")
/ Martin Nilsson (saturator)
Previous text:
2003-10-15 21:25: Subject: Timezones
The way I understand the Calendar Timezone design, that would be a nop (CEST and CET being synonyms for central european time); it's in the step before where the TimeRange gets its offset to the epoch where that something needs fixing.
/ Johan Sundström, Lysator
No, confusingly enough, the timezone for "CEST" isn't "CEST", it's "CET". "CEST" is just the abbreviation for "CET" in summer time. (Europeeans doesn't use daylight savings time, but summer time.)
| # Zone NAME GMTOFF RULES FORMAT [UNTIL] | Zone CET 1:00 C-Eur CE%sT | | # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S | Rule C-Eur 1981 max - Mar lastSun 2:00s 1:00 S | Rule C-Eur 1996 max - Oct lastSun 2:00s 0 -
But that doesn't matter much, the zone expert system should find CET from CEST anyway. But then the hard part appears - from that point it must understand that you mean time in or out of the summer time rule by specifying "CET" or "CEST".
/ Mirar
Previous text:
2003-10-15 21:20: Subject: Timezones
No, as the additional comment shows we just want "CET" to be parsed as CET and "CEST" as CEST. Currently the Timezone-complex refuses to understand DST.
Calendar.ISO.dwim_time("2001-01-01 01:01:01");
(1) Result: Second(Mon 1 Jan 2001 1:01:01 CET)
_->set_timezone("CEST");
No timezone "CEST" /home/nilsson/Pike/7.5/lib/modules/Calendar.pmod/Ruleset.pike:39: Calendar.Ruleset()->set_timezone(0) /home/nilsson/Pike/7.5/lib/modules/Calendar.pmod/TimeRanges.pmod:912: Second(Mon 1 Jan 2001 1:01:01 CET)->set_timezone("CEST")
/ Martin Nilsson (saturator)
Ok, so I can change the dwim rule (I didn't find any set_dst-method :)
if (sizeof(what)>19 && (t=parse(SPACED("%e %M %D %h:%m:%s %z DST %Y"),what,cx))) { string tz = t->tzname(); t->set_timezone( tz[..sizeof(tz)-2] + "S" + tz[sizeof(tz)-1..sizeof(tz)-1] ); return t; }
into
if (sizeof(what)>19 && (t=parse(SPACED("%e %M %D %h:%m:%s %z DST %Y"),what,cx))) return t;
?
/ Martin Nilsson (saturator)
Previous text:
2003-10-15 21:27: Subject: Timezones
No, confusingly enough, the timezone for "CEST" isn't "CEST", it's "CET". "CEST" is just the abbreviation for "CET" in summer time. (Europeeans doesn't use daylight savings time, but summer time.)
| # Zone NAME GMTOFF RULES FORMAT [UNTIL] | Zone CET 1:00 C-Eur CE%sT | | # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S | Rule C-Eur 1981 max - Mar lastSun 2:00s 1:00 S | Rule C-Eur 1996 max - Oct lastSun 2:00s 0 -
But that doesn't matter much, the zone expert system should find CET from CEST anyway. But then the hard part appears - from that point it must understand that you mean time in or out of the summer time rule by specifying "CET" or "CEST".
/ Mirar
Yes, or feed it into the timezone expert system (it takes a time and a zone abbreviaton or name and figures out a matching zone+time for that, iirc). dwim_zone?
That expert system should also handle the DST/summer time case.
/ Mirar
Previous text:
2003-10-15 21:30: Subject: Timezones
Ok, so I can change the dwim rule (I didn't find any set_dst-method :)
if (sizeof(what)>19 && (t=parse(SPACED("%e %M %D %h:%m:%s %z DST %Y"),what,cx))) { string tz = t->tzname(); t->set_timezone( tz[..sizeof(tz)-2] + "S" + tz[sizeof(tz)-1..sizeof(tz)-1] ); return t; }
into
if (sizeof(what)>19 && (t=parse(SPACED("%e %M %D %h:%m:%s %z DST %Y"),what,cx))) return t;
?
/ Martin Nilsson (saturator)
pike-devel@lists.lysator.liu.se