Branch: Tag:

2000-11-13

2000-11-13 13:51:00 by Mirar (Pontus Hagland) <pike@sort.mirar.org>

added format_nice and format_nicez

Rev: lib/modules/Calendar.pmod/Time.pmod:1.8
Rev: lib/modules/Calendar.pmod/YMD.pmod:1.19

704:   //! method string format_tod();   //! method string format_xtod();   //! method string format_mod(); + //! method string format_nice(); + //! method string format_nicez();   //! Format the object into nice strings;   //! <pre>   //! iso_ymd "2000-06-02 (Jun) -W22-5 (Fri)" [2]
720:   //! iso_time "2000-06-02 (Jun) -W22-5 (Fri) 20:53:14 UTC+1" [2]   //! ext_time "Friday, 2 June 2000, 20:53:14" [2]   //! ctime "Fri Jun 4 20:53:14 2000\n" [2] [3] - //! http "Fri, 02 Jun 2000 20:53:14 GMT" [4] + //! http "Fri, 02 Jun 2000 19:53:14 GMT" [4]   //! time "2000-06-02 20:53:14"   //! time_short "20000602 20:53:14"   //! time_xshort "000602 20:53:14"
732:   //! tod_short "205314"   //! xtod "20:53:14.000000"   //! mod "20:53" + //! nice "2 Jun 20:53", "2 Jun 2000 20:53:14" [2][5] + //! nicez "2 Jun 20:53 CET" [2][5] + //! smtp "Fri, 2 Jun 2000 20:53:14 +0100" [6]   //! </pre>   //! <tt>[1]</tt> note conflict (think 1 February 2003)   //! <br><tt>[2]</tt> language dependent   //! <br><tt>[3]</tt> as from the libc function ctime()   //! <br><tt>[4]</tt> as specified by the HTTP standard; - //! this is always in GMT, ie, UTC. The timezone calculations - //! needed will be executed implicitly. It is not language - //! dependent. + //! this is always in GMT, ie, UTC. The timezone calculations + //! needed will be executed implicitly. It is not language + //! dependent. + //! <br><tt>[5]</tt> adaptive to type and with special cases + //! for yesterday, tomorrow and other years + //! <br><tt>[6]</tt> as seen in Date: headers in mails       string format_ext_ymd();    string format_iso_ymd();
753:    string format_month();    string format_month_short();    +  string format_nice(); +     string format_iso_time()    {    return this_object()->format_iso_ymd()+" "+format_todz_iso();
853:    0);    }    +  string format_nice(); +  string format_nicez() +  { +  return format_nice()+" "+tzname(); +  } +  +  string format_smtp() +  { +  if (ls==CALUNKNOWN) make_local(); +  int u=utc_offset(); +  return sprintf("%s, %s %s %s %d:%02d:%02d %+03d%02d", +  base->week_day_name(), +  base->month_day_name(), +  base->month_shortname(), +  base->year_name(), +  ls/3600, (ls/60)%60, ls%60, +  -u/3600,max(u,-u)/60%60); +  } +     string format_elapsed()    {    string res="";
869:    left->len%60);    }    -  +    // --------       TimeofDay set_ruleset(Ruleset r)
1197:    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:00 %s",ls/3600,tzname());    } +  +  string format_nice() +  { +  if (ls==CALUNKNOWN) make_local(); +  if (!base) make_base(); +  return base->format_nice()+" "+sprintf("%d:00",ls/3600);    } -  + }      //------------------------------------------------------------------------   //! class Minute
1265:    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:%02d %s",ls/3600,(ls/60)%60,tzname());    } +  +  string format_nice() +  { +  if (ls==CALUNKNOWN) make_local(); +  if (!base) make_base(); +  return base->format_nice()+" "+sprintf("%d:%02d",ls/3600,(ls/60)%60);    } -  + }      //------------------------------------------------------------------------   //! class Second
1333:    return sprintf("%d:%02d:%02d %s",ls/3600,ls/60%60,ls%60,tzname());    }    +  string format_nice() +  { +  if (ls==CALUNKNOWN) make_local(); +  if (!base) make_base(); +  return base->format_nice()+" "+ +  sprintf("%d:%02d:%02d",ls/3600,ls/60%60,ls%60); +  } +    // backwards compatible with calendar I    string iso_name()    { return this_object()->format_ymd()+" T"+format_tod(); }
1553:    ls/3600,ls/60%60,ls%60,ns/1000,tzname());    }    +  string format_nice() +  { +  if (ls==CALUNKNOWN) make_local(); +  if (!base) make_base(); +  return base->format_nice()+" "+ +  sprintf("%d:%02d:%02d.%06d", +  ls/3600,ls/60%60,ls%60,ns/1000); +  } +     TimeofDay autopromote()    {    if (!ns && !len_ns)