2007-05-05 12:05:41 UTC by mbaehr
- Pike/7.7/lib/modules/Calendar.pmod/YMD.pike (+3/-5)
don't hardcode month and day names here
changes format_http() from using constant English strings to using Calendar's language bound day and month names. I don't contest that that format could be useful for some purposes, but shouldn't it use a different method name then? RFC 2616 states that a HTTP-date is:
HTTP-date = rfc1123-date | rfc850-date | asctime-date rfc1123-date = wkday "," SP date1 SP time SP "GMT" rfc850-date = weekday "," SP date2 SP time SP "GMT" asctime-date = wkday SP date3 SP time SP 4DIGIT date1 = 2DIGIT SP month SP 4DIGIT ; day month year (e.g., 02 Jun 1982) date2 = 2DIGIT "-" month "-" 2DIGIT ; day-month-year (e.g., 02-Jun-82) date3 = month SP ( 2DIGIT | ( SP 1DIGIT )) ; month day (e.g., Jun 2) time = 2DIGIT ":" 2DIGIT ":" 2DIGIT ; 00:00:00 - 23:59:59 wkday = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun" weekday = "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday" | "Sunday" month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
Examples of Calendar's less known features (swedish and roman latin):
Calendar.set_language("swedish")->Day()->week_day_shortname()
"sön"
Calendar.set_language("roman")->Day()->month_shortname();
"Mai"
I'm not sure if the Calendar module tries to do any environment sniffing of its own to pick up a suitable language, but it's been known to be a bit over-customizable by .h files, so I'd be wary of changes like these.
On Sun, May 06, 2007 at 01:10:00PM +0000, Johan Sundstr�m (Achtung Liebe!) @ Pike (-) developers forum wrote:
changes format_http() from using constant English strings to using Calendar's language bound day and month names. I don't contest that that format could be useful for some purposes, but shouldn't it use a different method name then? RFC 2616 states that a HTTP-date is:
well, as it was the format simply broke with other calendars.
what about format_smtp? doesn't the same issue apply there as well?
you are probably right though.
i guess a better fix would be to always convert to ISO before returning a value or refusing to allow format_http to work with other calendars and providing this result under a different function name.
thanks for keeping an eye on this...
greetings, martin.
On Sun, May 06, 2007 at 03:22:05PM +0200, Martin Bähr wrote:
i guess a better fix would be to always convert to ISO before returning a value or refusing to allow format_http to work with other calendars and providing this result under a different function name.
did that, but but the checkin was a bit hasty. aparently adding a new function is not trivial. but instead of backing it out again just to move it in again later i hope i can leave it for now until i find out why it fails. (there is no useful backtrace, maybe related to thefact that i am not using the latest pike version)
greetings, martin.
On Sun, May 06, 2007 at 04:01:38PM +0200, Martin Bähr wrote:
but instead of backing it out again just to move it in again later i hope i can leave it for now until i find out why it fails.
found it. duh!
might there be any issues with moving format_http to ISO? for any non-gregorian calendar the function only produces nonsense.
greetings, martin.
Ah, didn't think of the non-gregorians. :-) It is probably good moving it to ISO, if possible with some glue for other calendars to phone ISO for the http formatting. (It's no picknick figuring out where to do what how, though; I think one needs a fair amount of beard to get it to work right.)
changes format_http() from using constant English strings to using Calendar's language bound day and month names. I don't contest that that format could be useful for some purposes, but shouldn't it use a different method name then? RFC 2616 states that a HTTP-date is:
well, as it was the format simply broke with other calendars.
Broke as in backtraces (for some missing array index or similar)?
what about format_smtp? doesn't the same issue apply there as well?
Probably; I just keep a better eye on changes than the stale code base. :-) Feel free to reverse the fix, so that gets code similar to the original format_http (I haven't read up on the SMTP standard, but there usually is someone around who has) instead.
On Sun, May 06, 2007 at 02:05:01PM +0000, Johan Sundstr�m (Achtung Liebe!) @ Pike (-) developers forum wrote:
Broke as in backtraces (for some missing array index or similar)?
that too. it completely breaks if your calendar has a different set of months.
the function should really be moved to ISO
greetings, martin.
pike-devel@lists.lysator.liu.se