pike.git / lib / modules / Calendar.pmod / Time.pmod

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Time.pmod:19:   //- an hour is 3600 seconds, a minute is 60 seconds      inherit Calendar.TimeRanges:TimeRanges;      #include "constants.h"      // from inherited module      function(mixed...:TimeRange) Day;    - // sanity check -  - #ifndef __AUTO_BIGNUM__ - #error Calendar.Time needs bignums (Gmp.mpz) - #endif -  +    Calendar.Rule.Timezone Timezone_UTC=    Calendar.Rule.Timezone(0,"UTC"); // needed for dumping      string calendar_name() { return "Time"; }      //------------------------------------------------------------------------   //! class TimeofDay   //! Virtual class used by e.g. Hour.   //------------------------------------------------------------------------   
pike.git/lib/modules/Calendar.pmod/Time.pmod:65:   //! a time of day can also be constructed with unixtime   //! as single argument consisting of the unix time   //! - as returned from <tt>time(2)</tt> - of the time unit start.   //!   //! It can also be constructed without argument, which   //! then means "now", as in "this minute".      //- for internal use:   //- method void create("timeofday",rules,unixtime,len)    -  void create(mixed ...args) +  protected void create(mixed ...args)    {    if (!sizeof(args))    {    rules=default_rules;    create_now();    return;    }    switch (args[0])    {    case "timeofday":
pike.git/lib/modules/Calendar.pmod/Time.pmod:1219:   #undef RBASE      // count parts elapsed    string format_elapsed()    {    TimeRange z=parts[0];    foreach (parts,TimeRange y) z+=y;    return parts[0]->distance(z)->format_elapsed();    }    -  string _sprintf(int t,mapping m) +  protected string _sprintf(int t,mapping m)    {    if (t=='t')    return "Calendar."+calendar_name()+".TimeofDay";    return ::_sprintf(t,m);    }   }      class cNullTimeRange   {    inherit TimeRanges::cNullTimeRange;
pike.git/lib/modules/Calendar.pmod/Time.pmod:1259:      function(mixed...:cHour) Hour=cHour; // inheritance purposes   class cHour   {    constant is_hour=1;      //! inherits TimeofDay       inherit TimeofDay;    -  int __hash() { return ux/(60*60); } +  protected int __hash() { return ux/(60*60); }       void create_unixtime_default(int unixtime)    {    create_unixtime(unixtime,3600);    }       protected void create_now()    {    create_unixtime(time(),3600);    }
pike.git/lib/modules/Calendar.pmod/Time.pmod:1299:       TimeofDay _move(int n,int m)    {    if (m==0 || n==0) return this;    if (m%3600)    return Second("timeofday",rules,ux,len)->_move(n,m);    return Hour("timeofday",rules,ux+n*m,len)->autopromote();    }       -  string _sprintf(int t,mapping m) +  protected string _sprintf(int t,mapping m)    {    if (catch {    switch (t)    {    case 'O':    if (!base) make_base();    if (len!=3600)    return sprintf("Hour(%s)",    nice_print_period());    return sprintf("Hour(%s %s)",
pike.git/lib/modules/Calendar.pmod/Time.pmod:1371:      function(mixed...:cMinute) Minute=cMinute; // inheritance purposes   class cMinute   {    constant is_minute=1;      //! inherits TimeofDay       inherit TimeofDay;    -  int __hash() { return ux/60; } +  protected int __hash() { return ux/60; }       protected void create_unixtime(int _ux,int _len)    {    ::create_unixtime(_ux,_len);    if (ls==CALUNKNOWN) make_local();    ux-=ls%60;    }       void create_unixtime_default(int unixtime)    {
pike.git/lib/modules/Calendar.pmod/Time.pmod:1411:    len-=len%60;    }       TimeofDay _move(int n,int m)    {    if (m==0 || n==0) return this;    if (m%60) return Second("timeofday",rules,ux,len)->_move(n,m);    return Minute("timeofday",rules,ux+n*m,len)->autopromote();    }    -  string _sprintf(int t,mapping m) +  protected string _sprintf(int t,mapping m)    {    switch (t)    {    case 'O':    if (!base) make_base();    if (len!=60)    return sprintf("Minute(%s)",    nice_print_period());    return sprintf("Minute(%s %s)",    base->nice_print(),
pike.git/lib/modules/Calendar.pmod/Time.pmod:1478:      function(mixed...:cSecond) Second=cSecond; // inheritance purposes   class cSecond   {    constant is_second=1;      //! inherits TimeofDay       inherit TimeofDay;    -  int __hash() { return ux; } +  protected int __hash() { return ux; }       void create_unixtime_default(int unixtime)    {    create_unixtime(unixtime,1);    }       protected void create_now()    {    create_unixtime(time(),1);    }
pike.git/lib/modules/Calendar.pmod/Time.pmod:1510:    return Minute("timeofday",rules,ux,len)->autopromote();    return ::autopromote();    }       TimeofDay _move(int n,int m)    {    if (m==0 || n==0) return this;    return Second("timeofday",rules,ux+n*m,len)->autopromote();    }    -  string _sprintf(int t,mapping m) +  protected string _sprintf(int t,mapping m)    {    switch (t)    {    case 'O':    if (len!=1)    return sprintf("Second(%s)",    nice_print_period());    if (!base) make_base();    return sprintf("Second(%s %s)",    base->nice_print(),
pike.git/lib/modules/Calendar.pmod/Time.pmod:1621:   //! and the size of the period can be given in floats,   //! both representing seconds. Note that the default   //! float precision in pike is rather low (same as 'float' in C,   //! the 32 bit floating point precision, normally about 7 digits),   //! so beware that the resolution might bite you. (Internally   //! in a Fraction, the representation is an integer.)   //!   //! If created without explicit length, the fraction will always be   //! of zero length.    -  void create(mixed ...args) +  protected void create(mixed ...args)    {    if (!sizeof(args))    {    rules=default_rules;    create_now();    return;    }    else if (args[0]=="timeofday_f")    {    rules=[object(Calendar.Ruleset)]args[1];
pike.git/lib/modules/Calendar.pmod/Time.pmod:1768:    {   // 1970-01-01 is julian day 2440588    jd-=2440588;    float fjd=((jd-(int)jd)+0.5)*86400;    ux=((int)jd)*86400+(int)(fjd);    ns=(int)(inano*(fjd-(int)fjd));       ls=CALUNKNOWN;    }    -  string _sprintf(int t,mapping m) +  protected string _sprintf(int t,mapping m)    {    switch (t)    {    case 'O':    if (!base) make_base();    if (len_ns || len_s)    return sprintf("Fraction(%s)",    nice_print_period());    return sprintf("Fraction(%s %s)",    base->nice_print(),    nice_print());    case 't':    return "Calendar."+calendar_name()+".Fraction";    default:    return ::_sprintf(t,m);    }    }    -  int __hash() { return ux; } +  protected int __hash() { return ux; }       string nice_print()    {    if (ls==CALUNKNOWN) make_local();    return sprintf("%d:%02d:%02d.%06d %s",    ls/3600,ls/60%60,ls%60,ns/1000,tzname());    }       string format_nice()    {