Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.mainResponder.localization.dateTimeString
on dateTimeString (d, pta=nil) {
<<Gets the localized version of a 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
<<Changes:
<<05/17/00 6:38:19 PM by JS
<<optimized -- no longer call mainResponder.localization.getDateTimeReplacementTable, rather build the table here
<<06/28/00; 1:05:16 AM by JES
<<Fixed problem with midnight hour on 12-hour clocks displaying as 0:xx:xx
if pta == nil {
pta = html.getPageTableAddress ()};
local (adrLanguageTable = mainResponder.localization.getLanguageTableAddress (pta));
local (langName = nameOf (adrLanguageTable^));
if defined (temp.mainResponder.localizationCache.[langName].dateTimeStrings.[d]) {
return (temp.mainResponder.localizationCache.[langName].dateTimeStrings.[d])};
local (fl24HourClock = adrLanguageTable^.strings.date.use24HourClock);
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.month = mo;
replacementTable.day = day;
replacementTable.yy = string.mid (yr, 3, 2);
if fl24HourClock {
replacementTable.hour = hr;
replacementTable.["am/pm"] = ""}
else { // 12-hour clock
if hr > 11 {
if hr > 12 {
hr = hr - 12};
replacementTable.hour = hr;
replacementTable.["am/pm"] = adrLanguageTable^.strings.date.meridianNames.pm}
else {
if hr == 0 { // 06/28/00 JES: fix zero-hour problem with 12-hour clocks
hr = 12};
replacementTable.hour = hr;
replacementTable.["am/pm"] = adrLanguageTable^.strings.date.meridianNames.am}};
replacementTable.mm = string.padWithZeros (min, 2);
replacementTable.ss = string.padWithZeros (sec, 2);
local (s);
s = mainResponder.getString ("date.dateTime", @replacementTable, pta: pta);
if defined (temp.mainResponder.localizationCache.[langName]) {
local (adrCache = @temp.mainResponder.localizationCache.[langName].dateTimeStrings);
if not defined (adrCache^) {
new (tableType, adrCache)};
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.