Monday, November 08, 2010 at 12:04 AM.


on longDateString (d, pta=nil) {
	<<Gets the localized version of a long date string for a given date value.
		<<d is a date or a string that can be coerced to a date
	<<4/13/00; 2:39:54 PM by JES
		<<05/17/00 6:38:19 PM by JS
			<<optimized -- no longer call mainResponder.localization.getDateTimeReplacementTable, rather build the table here
		<<9/26/01; 7:18:25 PM by PBS
			<<Use caching.
	if pta == nil {
		pta = html.getPageTableAddress ()};
	local (adrLanguageTable = mainResponder.localization.getLanguageTableAddress (pta));
	local (langName = nameOf (adrLanguageTable^));
	if defined (temp.mainResponder.localizationCache.[langName].longDates.[d]) {
		return (temp.mainResponder.localizationCache.[langName].longDates.[d])};
	local (replacementTable); new (tableType, @replacementTable); // 05/01/00 JES: use replacement table instead of a list
	local (yr, mo, day, hr, min, sec);
	date.get (d, @day, @mo, @yr, @hr, @min, @sec);
	replacementTable.dayOfWeek = adrLanguageTable^[date.dayOfWeek (d)]; = day;
	replacementTable.monthName = adrLanguageTable^[string.padWithZeros (mo, 2)];
	replacementTable.year = yr;
	local (s);
	s = mainResponder.getString ("date.longDate", @replacementTable, pta: pta);
	if defined (temp.mainResponder.localizationCache.[langName]) {
		local (adrCache = @temp.mainResponder.localizationCache.[langName].longDates);
		if not defined (adrCache^) {
			new (tableType, adrCache)};
		if d != "" {
			adrCache^.[d] = s}};
	return (s)}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.