[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Suggestions for date formats



> > Standards are good. Feel free to convert the pages to use this
> > format and generate the necessary scripts. If you are stuck for
> > time, or can't generate the scripts for some reason, just ask.
> I'll see if I can come up with anything productive.

Hmmm. What I want to do, is to feed the <define-tag release_date> to a Perl
function that transforms the date according to the current language
(somewhat like template/debian/ctime.wml, but not entirely, especially it
should only be the date, and in a more compact format).

Writing the Perl function shouldn't be that hard, feeding it with the date
in YYYY-MM-DD format (which of course needs rewriting of all existing
news/security pages) is harder, since I don't know the wml syntax to do
that.


Putting the function in ctime.wml would probably be the best, since the
month names are defined there (for those languages where writing the name of
the month is the best idea, for Swedish, I'll just use the YYYY-MM-DD
format, since that's what is defined as Swedish standard).


I was thinking of something like this to add to ctime.wml:

===( cut )===
%newsdateform = (
	sv => '"%4d-%02d-%02d", $year, $mon, $mday'
);

sub newsdate {
	my ($year, $mon, $mday) = split /-/, $_[0];
	return $_[0] unless $mday;
	return $_[0] if ($year < 1900);

	$mon_str = $moy{$CUR_ISO_LANG}[$mon - 1];
	return defined($newsdateform{$CUR_ISO_LANG}) ?
	       eval("sprintf($newsdateform{$CUR_ISO_LANG})") :
	       sprintf("%02d %s %04d", $mday, $mon_str, $year);
}
===( cut )===

What do you think? I've tried to have two sanity checks to see if it really
is in YYYY-MM-DD format, and if not, just returns the string (this will make
old strings in "Dd Mmm YYYY" format show up as before.

-- 
\\//
peter - http://www.softwolves.pp.se/
      - and God said: nohup make World >& World.log &


Reply to: