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

version» Context lines:

pike.git/lib/modules/Calendar.pmod/Stardate.pmod:1:   //! module Calendar   //! submodule Stardate   //! This implements TNG stardates.      #pike __REAL_VERSION__    - import "."; + inherit .TimeRanges;    - inherit TimeRanges; -  +    static constant TNGSTARPERJULIAN=1000.0/365.2425;   static constant TNGSTARPERSECOND=TNGSTARPERJULIAN/86400;   static constant TNG0JULIAN=2569518.5;   static constant TNG0UNIX=11139552000;      string calendar_name() { return "Stardate"; }      function(mixed...:cTick) Tick=cTick;   class cTick   {
pike.git/lib/modules/Calendar.pmod/Stardate.pmod:132:    int unix_time()    {    return ((int)(t/TNGSTARPERSECOND))+TNG0UNIX;    }       float julian_day()    {    return ((int)(t/TNGSTARPERJULIAN))+TNG0JULIAN;    }    -  TimeRange add(int n,void|this_program step) +  static TimeRange _add(int n,void|this_program step)    {    float x;    if (!step)    x=len;    else    {    if (!step->is_stardate)    error("add: Incompatible type %O\n",step);    x=step->len;    }
pike.git/lib/modules/Calendar.pmod/Stardate.pmod:217:       TimeRange distance(TimeRange to)    {    if (!to->is_stardate)    error("distance: Incompatible type %O\n",to);    if (to->t<t)    error("negative distance\n");    return Tick("stardate",rules,t,to->t-t);    }    -  array _compare(TimeRange with) +  array(int(-1..1)) _compare(TimeRange with)    {    float b1=t;    float e1=t+len;    float b2,e2;    if (with->is_stardate)    b2=with->t,e2=b2+with->len;    else    ::_compare(with);   #define CMP(A,B) ( ((A)<(B))?-1:((A)>(B))?1:0 )    return ({ CMP(b1,b2),CMP(b1,e2),CMP(e1,b2),CMP(e1,e2) });    }       int __hash() { return (int)t; }    -  cTick set_ruleset(Ruleset r) +  TimeRange set_ruleset(.Ruleset r)    {    return Tick("stardate",r,t,len);    }    -  string _sprintf(int t) +  string _sprintf(int t, mapping m)    {    switch (t)    {    case 'O':    if (len!=0.0)    return sprintf("Tick(%s)",nice_print_period());    return sprintf("Tick(%s)",nice_print());    default:    return 0;    }
pike.git/lib/modules/Calendar.pmod/Stardate.pmod:299:   // compat   function(mixed...:cTick) TNGDate=cTick;      // for events   function(mixed...:cTick) Day=cTick;      //------------------------------------------------------------------------   // global convinience functions   //------------------------------------------------------------------------    - //! method TimeofDay now() + //! method Time.TimeofDay now()   //! Give the zero-length time period of the   //! current time.    - TimeofDay now() + .Time.TimeofDay now()   {    return Tick();   }