[alicebot-archcomm] Date output

Ernest Lergon alicebot-archcomm@list.alicebot.org
Sat, 26 Jul 2003 19:23:24 +0200


Proposal:

    <date [format="{format}"] [lang="{lang}"]/>

    {format} := "DD.MM.YYYY hh:mm:ss" |
                "YYYY-MM-DD hh:mm:ss TZ" |
                "wd, DD Mn YYYY hh:mm:ss TZ" |
                | etc...

    e.g.:       "26.07.2003 15:20:32"
                "2003-07-26 15:20:32 GMT"
                "Sat, 26 Jul 2003 15:20:32 GMT"

    {lang}   := 'de' | 'us' | 'en' | etc...

We should extend the <date> tag with attributes defining the output
format of the date to reflect the different international usage and
languages. Moreover it might be useful to just ouput the year or the
weekday.

E.g.:
2003-07-26:
    <date format="YYYY"/>             --->  2003
    <date format="Mnl" lang="en"/>    --->  July
    <date format="Mnl" lang="de"/>    --->  Juli
    <date format="Mn"/>               --->  Jul
    <date format="wd"/>               --->  Sat       (default lang="en")
    <date format="wdl"/>              --->  Saturday  (default lang="en")
    <date format="wdl" lang="de"/>    --->  Samstag

2003-05-08
    <date format="Mn"/>               --->  May  (default lang="en")
    <date format="Mn" lang="de"/>     --->  Mai

An extension might be to let the botmaster define the month and day
names in the startup files like this:

<startup>
    <setup>
       <date lang="en">
          <months>
             <month value="1" long="January"  short="Jan"/>
             <month value="5" long="May"      short="May"/>
          </months>
          <days>
             <day   value="1" long="Monday"   short="Mon"/>
             <day   value="2" long="Tuesday"  short="Tue"/>
          </days>
       </date>
       <date lang="de">
          <months>
             <month value="1" long="Januar"   short="Jan"/>
             <month value="5" long="Mai"      short="Mai"/>
          </months>
          <days>
             <day   value="1" long="Montag"   short="Mon"/>
             <day   value="2" long="Dienstag" short="Die"/>
          </days>
       </date>
    </setup>
</startup>

The AIML interpreter must raise a fatal error at load-time, if a value
of the attribute 'lang' is not predefined as well if a month/date entry
is missing.

The format strings have to be discussed. Maybe we should keep the format
strings simple - aka not use the PHP or Unix approach.
See:
http://java.sun.com/j2se/1.4/docs/api/java/text/SimpleDateFormat.html
http://php.planetmirror.com/manual/sl/print/function.date.php
http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=linux&db=man&fname=/usr/share/catman/man1/date.1.html

Ernest

-- 
               ProgramV - Alice on Perl - available at
                http://www.virtualitas.net/perl/aiml/

       VIRTUALITAS - Manufacturer of fine OOPPS - since 1996
*********************************************************************
* VIRTUALITAS Inc.               *       http://www.virtualitas.net *
* Ernest Lergon                  *    mailto:Ernest@virtualitas.net *
*********************************************************************
       PGP-Fingerprint 6E6F DC17 A886 342D  D63F 7880 12F5 6BA9
         PGP-Key http://www.virtualitas.net/Ernest_Lergon.asc

---------------------------------------------------------------------
SPAM ALERT                       http://www.virtualitas.net/spam.html
---------------------------------------------------------------------