Branch: Tag:

2000-09-26

2000-09-26 19:00:27 by Fredrik Hübinette (Hubbe) <hubbe@hubbe.net>

oops, I forgot to check some stuff in yesterday...

Rev: lib/7.0/include/simulate.h:1.1
Rev: lib/7.0/modules/Simulate.pmod:1.1
Rev: lib/7.0/modules/__default.pmod:1.1
Rev: lib/master.pike.in:1.132
Rev: lib/modules/ADT.pmod/Heap.pike:1.4
Rev: lib/modules/ADT.pmod/Priority_queue.pike:1.3
Rev: lib/modules/ADT.pmod/Queue.pike:1.2
Rev: lib/modules/ADT.pmod/Table.pmod:1.13
Rev: lib/modules/ADT.pmod/struct.pike:1.7
Rev: lib/modules/Array.pmod:1.45
Rev: lib/modules/Cache.pmod/Data.pike:1.2
Rev: lib/modules/Cache.pmod/Policy.pmod/Base.pike:1.2
Rev: lib/modules/Cache.pmod/Policy.pmod/Multiple.pike:1.2
Rev: lib/modules/Cache.pmod/Policy.pmod/Null.pike:1.2
Rev: lib/modules/Cache.pmod/Policy.pmod/Sized.pike:1.2
Rev: lib/modules/Cache.pmod/Policy.pmod/Timed.pike:1.2
Rev: lib/modules/Cache.pmod/Storage.pmod/Base.pike:1.3
Rev: lib/modules/Cache.pmod/Storage.pmod/Gdbm.pike:1.3
Rev: lib/modules/Cache.pmod/Storage.pmod/Memory.pike:1.3
Rev: lib/modules/Cache.pmod/Storage.pmod/MySQL.pike:1.2
Rev: lib/modules/Cache.pmod/Storage.pmod/Yabu.pike:1.3
Rev: lib/modules/Cache.pmod/cache.pike:1.3
Rev: lib/modules/Calendar.pmod/Austrian.pmod:1.3
Rev: lib/modules/Calendar.pmod/Calendar.pike:1.2
Rev: lib/modules/Calendar.pmod/Coptic.pmod:1.2
Rev: lib/modules/Calendar.pmod/Discordian.pmod:1.2
Rev: lib/modules/Calendar.pmod/Event.pmod:1.6
Rev: lib/modules/Calendar.pmod/Gregorian.pmod:1.2
Rev: lib/modules/Calendar.pmod/ISO.pmod:1.2
Rev: lib/modules/Calendar.pmod/Islamic.pmod:1.2
Rev: lib/modules/Calendar.pmod/Julian.pmod:1.2
Rev: lib/modules/Calendar.pmod/Language.pmod:1.5
Rev: lib/modules/Calendar.pmod/Namedays.pmod:1.2
Rev: lib/modules/Calendar.pmod/Roman.pmod:1.2
Rev: lib/modules/Calendar.pmod/Ruleset.pike:1.4
Rev: lib/modules/Calendar.pmod/Stardate.pmod:1.2
Rev: lib/modules/Calendar.pmod/Swedish.pmod:1.3
Rev: lib/modules/Calendar.pmod/TZnames.pmod:1.4
Rev: lib/modules/Calendar.pmod/Time.pmod:1.3
Rev: lib/modules/Calendar.pmod/TimeRanges.pmod:1.7
Rev: lib/modules/Calendar.pmod/Timezone.pmod:1.9
Rev: lib/modules/Calendar.pmod/YMD.pmod:1.11
Rev: lib/modules/Calendar.pmod/mkrules.pike:1.3
Rev: lib/modules/Calendar.pmod/module.pmod:1.5
Rev: lib/modules/Colors.pmod:1.5
Rev: lib/modules/Crypto.pmod:1.5
Rev: lib/modules/Crypto/_rsa.pike:1.4
Rev: lib/modules/Crypto/des3.pike:1.5
Rev: lib/modules/Crypto/des3_cbc.pike:1.3
Rev: lib/modules/Crypto/des_cbc.pike:1.3
Rev: lib/modules/Crypto/dsa.pike:1.8
Rev: lib/modules/Crypto/hmac.pike:1.6
Rev: lib/modules/Crypto/idea_cbc.pike:1.3
Rev: lib/modules/Crypto/randomness.pmod:1.17
Rev: lib/modules/Crypto/rsa.pike:1.26
Rev: lib/modules/Debug.pmod/werror.pmod:1.4
Rev: lib/modules/Filesystem.pmod/System.pike:1.5
Rev: lib/modules/Filesystem.pmod/Tar.pmod:1.8
Rev: lib/modules/Filesystem.pmod/module.pmod:1.7
Rev: lib/modules/Function.pmod:1.2
Rev: lib/modules/GDK.pmod:1.8
Rev: lib/modules/GLU.pmod:1.7
Rev: lib/modules/GTKSupport.pmod/Alert.pike:1.4
Rev: lib/modules/GTKSupport.pmod/MenuFactory.pmod:1.4
Rev: lib/modules/GTKSupport.pmod/SClist.pike:1.5
Rev: lib/modules/GTKSupport.pmod/Util.pmod:1.7
Rev: lib/modules/GTKSupport.pmod/pCtree.pike:1.4
Rev: lib/modules/GTKSupport.pmod/pDrawingArea.pike:1.4
Rev: lib/modules/Geography.pmod/Countries.pmod:1.3
Rev: lib/modules/Geography.pmod/Position.pike:1.3
Rev: lib/modules/Getopt.pmod:1.10
Rev: lib/modules/Gnome.pmod:1.2
Rev: lib/modules/Graphics.pmod/Graph.pmod/create_bars.pike:1.2
Rev: lib/modules/Graphics.pmod/Graph.pmod/create_graph.pike:1.3
Rev: lib/modules/Graphics.pmod/Graph.pmod/create_pie.pike:1.3
Rev: lib/modules/Graphics.pmod/Graph.pmod/module.pmod:1.3
Rev: lib/modules/Graphics.pmod/Graph.pmod/polyline.pike:1.2
Rev: lib/modules/Graphics.pmod/Graph.pmod/test.pike:1.3
Rev: lib/modules/LR.pmod/Grammar_parser.pmod:1.9
Rev: lib/modules/LR.pmod/item.pike:1.5
Rev: lib/modules/LR.pmod/lr.pike:1.4
Rev: lib/modules/LR.pmod/parser.pike:1.23
Rev: lib/modules/LR.pmod/priority.pike:1.3
Rev: lib/modules/LR.pmod/rule.pike:1.6
Rev: lib/modules/LR.pmod/scanner.pike:1.2
Rev: lib/modules/Languages.pmod/PLIS.pmod:1.9
Rev: lib/modules/Locale.pmod/Charset.pmod:1.2
Rev: lib/modules/Locale.pmod/Gettext.pmod:1.2
Rev: lib/modules/Locale.pmod/module.pmod:1.3
Rev: lib/modules/Parser.pmod/C.pmod:1.15
Rev: lib/modules/Parser.pmod/Pike.pmod:1.3
Rev: lib/modules/Parser.pmod/XML.pmod/Simple.pike:1.2
Rev: lib/modules/Parser.pmod/XML.pmod/Tree.pmod:1.4
Rev: lib/modules/Parser.pmod/module.pmod:1.2
Rev: lib/modules/Process.pmod:1.28
Rev: lib/modules/Program.pmod:1.2
Rev: lib/modules/Protocols.pmod/DNS.pmod:1.50
Rev: lib/modules/Protocols.pmod/HTTP.pmod/Query.pike:1.19
Rev: lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:1.15
Rev: lib/modules/Protocols.pmod/IMAP.pmod/dummy_server.pike:1.6
Rev: lib/modules/Protocols.pmod/IMAP.pmod/imap_server.pike:1.19
Rev: lib/modules/Protocols.pmod/IMAP.pmod/parse_line.pike:1.24
Rev: lib/modules/Protocols.pmod/IMAP.pmod/parser.pike:1.11
Rev: lib/modules/Protocols.pmod/IMAP.pmod/requests.pmod:1.88
Rev: lib/modules/Protocols.pmod/IMAP.pmod/server.pike:1.13
Rev: lib/modules/Protocols.pmod/IMAP.pmod/types.pmod:1.26
Rev: lib/modules/Protocols.pmod/IRC.pmod/Client.pike:1.3
Rev: lib/modules/Protocols.pmod/IRC.pmod/Error.pmod:1.2
Rev: lib/modules/Protocols.pmod/IRC.pmod/Raw.pike:1.3
Rev: lib/modules/Protocols.pmod/IRC.pmod/Requests.pmod:1.2
Rev: lib/modules/Protocols.pmod/Ident.pmod:1.8
Rev: lib/modules/Protocols.pmod/LDAP.pmod/client.pike:1.19
Rev: lib/modules/Protocols.pmod/LDAP.pmod/ldap_privates.pmod:1.5
Rev: lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:1.5
Rev: lib/modules/Protocols.pmod/LPD.pmod:1.5
Rev: lib/modules/Protocols.pmod/Line.pmod:1.10
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/ASync.pmod:1.2
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Connection.pike:1.6
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Helper.pmod:1.4
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/ProtocolTypes.pmod:1.6
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike:1.9
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Request.pmod:1.6
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Session.pike:1.20
Rev: lib/modules/Protocols.pmod/LysKOM.pmod/Threads.pike:1.6
Rev: lib/modules/Protocols.pmod/NNTP.pmod:1.8
Rev: lib/modules/Protocols.pmod/Ports.pmod:1.6
Rev: lib/modules/Protocols.pmod/SMTP.pmod:1.12
Rev: lib/modules/Protocols.pmod/TELNET.pmod:1.10
Rev: lib/modules/Protocols.pmod/X.pmod/Atom.pmod:1.6
Rev: lib/modules/Protocols.pmod/X.pmod/Auth.pmod:1.8
Rev: lib/modules/Protocols.pmod/X.pmod/Extensions.pmod:1.9
Rev: lib/modules/Protocols.pmod/X.pmod/Requests.pmod:1.27
Rev: lib/modules/Protocols.pmod/X.pmod/Types.pmod:1.33
Rev: lib/modules/Protocols.pmod/X.pmod/XImage.pmod:1.15
Rev: lib/modules/Protocols.pmod/X.pmod/XTools.pmod:1.5
Rev: lib/modules/Protocols.pmod/X.pmod/Xlib.pmod:1.40
Rev: lib/modules/Protocols.pmod/X.pmod/_Types.pmod:1.4
Rev: lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod:1.14
Rev: lib/modules/Protocols.pmod/X.pmod/db/convert_compose.pike:1.3
Rev: lib/modules/Remote.pmod/Client.pike:1.8
Rev: lib/modules/Remote.pmod/Server.pike:1.8
Rev: lib/modules/Remote.pmod/call.pike:1.6
Rev: lib/modules/Remote.pmod/connection.pike:1.18
Rev: lib/modules/Remote.pmod/context.pike:1.11
Rev: lib/modules/Remote.pmod/obj.pike:1.4
Rev: lib/modules/Sql.pmod/msql.pike:1.8
Rev: lib/modules/Sql.pmod/mysql.pike:1.11
Rev: lib/modules/Sql.pmod/mysql_result.pike:1.3
Rev: lib/modules/Sql.pmod/odbc.pike:1.6
Rev: lib/modules/Sql.pmod/odbc_result.pike:1.3
Rev: lib/modules/Sql.pmod/oracle.pike:1.5
Rev: lib/modules/Sql.pmod/postgres.pike:1.10
Rev: lib/modules/Sql.pmod/postgres_result.pike:1.3
Rev: lib/modules/Sql.pmod/rsql.pike:1.5
Rev: lib/modules/Sql.pmod/sql.pike:1.39
Rev: lib/modules/Sql.pmod/sql_result.pike:1.6
Rev: lib/modules/Sql.pmod/sql_util.pmod:1.5
Rev: lib/modules/Sql.pmod/sybase.pike:1.4
Rev: lib/modules/Stack.pmod:1.6
Rev: lib/modules/Standards.pmod/ASN1.pmod/Decode.pmod:1.10
Rev: lib/modules/Standards.pmod/ASN1.pmod/Encode.pmod:1.5
Rev: lib/modules/Standards.pmod/ASN1.pmod/Types.pmod:1.15
Rev: lib/modules/Standards.pmod/ISO639_2.pmod:1.3
Rev: lib/modules/Standards.pmod/PKCS.pmod/CSR.pmod:1.7
Rev: lib/modules/Standards.pmod/PKCS.pmod/Certificate.pmod:1.7
Rev: lib/modules/Standards.pmod/PKCS.pmod/DSA.pmod:1.4
Rev: lib/modules/Standards.pmod/PKCS.pmod/Identifiers.pmod:1.9
Rev: lib/modules/Standards.pmod/PKCS.pmod/PFX.pmod:1.5
Rev: lib/modules/Standards.pmod/PKCS.pmod/RSA.pmod:1.13
Rev: lib/modules/Standards.pmod/PKCS.pmod/Signature.pmod:1.3
Rev: lib/modules/Stdio.pmod/Readline.pike:1.36
Rev: lib/modules/Stdio.pmod/Terminfo.pmod:1.10
Rev: lib/modules/Stdio.pmod/module.pmod:1.88
Rev: lib/modules/String.pmod:1.12
Rev: lib/modules/Thread.pmod:1.22
Rev: lib/modules/Tools.pmod/Hilfe.pmod:1.15
Rev: lib/modules/Tools.pmod/Install.pmod:1.8
Rev: lib/modules/Tools.pmod/PEM.pmod:1.7
Rev: lib/modules/Tools.pmod/X509.pmod:1.11
Rev: lib/modules/Tools.pmod/_PEM.pmod:1.3
Rev: lib/modules/Tools.pmod/sed.pmod:1.2
Rev: lib/modules/Yabu.pmod/module.pmod:1.23
Rev: lib/modules/Yabu.pmod/test.pike:1.7
Rev: lib/modules/_Image.pmod/module.pmod:1.10
Rev: lib/modules/_Image_PS.pmod:1.3
Rev: lib/modules/_Image_PSD.pmod:1.8
Rev: lib/modules/_Image_XCF.pmod:1.11
Rev: lib/modules/_Image_XPM.pmod:1.11
Rev: lib/modules/__builtin.pmod:1.2
Rev: lib/modules/error.pmod:1.3

1: - //! module Calendar +    //! submodule Stardate - //! This implements TNG stardates. + //! time unit: TNGDate    - import "."; + //! class TNGDate + //! implements ST:TNG stardates + //! can be used as create argument to Day    - inherit TimeRanges; + #pike __VERSION__    - static constant TNGSTARPERJULIAN=1000.0/365.2425; - static constant TNGSTARPERSECOND=TNGSTARPERJULIAN/86400; - static constant TNG0JULIAN=2569518.5; - static constant TNG0UNIX=11139552000; + class TNGDate + { +  inherit Calendar._TimeUnit;    - string calendar_name() { return "Stardate"; } +  // 40759.5 2363-10-05 2584405 +  // 47391.2 2370-05-23 2586827    - function(mixed...:cTick) Tick=cTick; - class cTick - { -  inherit TimeRange; +  // 50893.5 2373-11-23 2588107    -  constant is_stardate=1; +  // 6631.7 ---------- 2422 +  // 10134.0 ---------- 3702 +  // 1000.0 ---------- 365.2425 +  // 0.0 - - 2569519 + #define TNGSTARPERJULIAN (1000.0/365.2425)    -  float tick; -  float len; + //-- variables ------------------------------------------------------    - //! method void create(mixed ...) - //! method void create(int|float date) - //! method void create() - //! Apart from the standard creation methods - //! (julian day, etc), you can create a stardate - //! from the stardate number. The length - //! of the period will then be zero. - //! - //! You can also omit any arguments to create now. - //! - //! known bugs: - //! Since the precision is limited to the float type - //! of pike you can get non-precise results: - //! - //! <pre> - //! > Calendar.Second(Calendar.Stardate.Day(Calendar.Year())); - //! Result: Second(Fri 31 Dec 1999 23:59:18 CET - Sun 31 Dec 2000 23:59:18 CET) - //! </pre> +  float jd; +  float tics;    -  + //-- standard methods -----------------------------------------------    -  void create(mixed ...args) +  void create(int|float|object ... day)    { -  switch (sizeof(args)) +  float jd; +  if (!sizeof(day)) +  day=({Calendar.Gregorian.Second()}); +  else if (floatp(day[0]))    { -  case 4: -  // internal -  if (args[0]=="stardate") -  { -  rules=args[1]; -  tick=args[2]; -  len=args[3]; +  from_stardate(day[0]);    return;    } -  break; -  case 1: -  if (intp(args[0]) || floatp(args[0])) +  if (!intp(day[0]))    { -  rules=default_rules; -  tick=(float)args[0]; -  len=0.0; -  return; -  } -  break; -  case 0: -  rules=default_rules; -  create_unixtime_default(time()); -  return; -  } -  rules=default_rules; -  ::create(@args); -  } +  object o=day[0];    -  static void create_unixtime(int unixtime,int seconds) +  if (o->julian_day || o->julian_day_f) +  jd=(float)(o->julian_day_f||o->julian_day)(); +  else // dig +  if (o->day) // larger    { -  tick=(unixtime-TNG0UNIX)*TNGSTARPERSECOND; -  len=seconds*TNGSTARPERSECOND; -  } -  -  static void create_unixtime_default(int unixtime) -  { -  tick=(unixtime-TNG0UNIX)*TNGSTARPERSECOND; -  len=0.0; -  } -  -  static void create_julian_day(int|float jd) -  { -  tick=(jd-TNG0JULIAN)*TNGSTARPERJULIAN; -  len=0.0; -  } -  - //! method float tics() - //! This gives back the number of stardate tics - //! in the period. -  -  float tics() -  { -  return len; -  } -  - //! method int number_of_seconds() - //! method int number_of_days() - //! This gives back the Gregorian/Earth/ISO number of seconds - //! and number of days, for convinience and conversion to - //! other calendars. -  -  int number_of_seconds() -  { -  return (int)(len/TNGSTARPERSECOND); -  } -  -  int number_of_days() -  { -  return (int)(len/TNGSTARPERJULIAN); -  } -  -  int unix_time() -  { -  return ((int)(tick/TNGSTARPERSECOND))+TNG0UNIX; -  } -  -  float julian_day() -  { -  return ((int)(tick/TNGSTARPERJULIAN))+TNG0JULIAN; -  } -  -  TimeRange add(int n,void|this_program step) -  { -  float x; -  if (!step) -  x=len; +  o=o->day(0); +  if (o->julian_day_f) +  jd=o->julian_day_f(); +  else if (o->julian_day) +  jd=(float)o->julian_day();    else -  { -  if (!step->is_stardate) -  error("add: Incompatible type %O\n",step); -  x=step->len; +  ; // error, like    } -  -  -  if (n&&x) -  return Tick("stardate",rules,tick+x,len); -  return this_object(); -  } -  -  static void convert_from(TimeRange other) +  else // smaller    { -  if (other->unix_time) -  create_unixtime_default(other->unix_time()); -  else -  ::convert_from(other); -  if (other->is_stardate) +  float z=1.0; +  while (sizeof(o->greater()))    { -  tick=other->tick; -  len=other->len; -  } -  else if (other->number_of_seconds) -  len=TNGSTARPERSECOND*other->number_of_seconds(); -  else if (other->number_of_days) -  len=TNGSTARPERJULIAN*other->number_of_days(); -  else -  len=0.0; -  } -  -  static TimeRange _set_size(int n,TimeRange x) +  string name=o->is(); +  o=o[o->greater()[0]](); +  z*=o["number_of_"+name+"s"](); +  if (o->julian_day_f || o->julian_day)    { -  if (!x->is_stardate) -  error("distance: Incompatible type %O\n",x); -  return Tick("stardate",rules,tick,x->len); +  jd=(o->julian_day||o->julian_day_f)()/z; +  break;    } -  -  TimeRange place(TimeRange what,void|int force) -  { - // can't do this -  return this_object(); +     } -  -  array(TimeRange) split(int n) -  { -  if (!n) return ({this_object()}); // foo -  -  float z=tick; -  float l=len/n; -  array(TimeRange) res=({}); -  -  while (n--) -  res+=({Tick("stardate",rules,z,l)}),z+=l; -  -  return res; +     } -  -  TimeRange beginning() -  { -  if (!len) return this_object(); -  return Tick("stardate",rules,tick,0.0); +     } -  -  TimeRange end() -  { -  if (!len) return this_object(); -  return Tick("stardate",rules,tick+len,0.0); -  } -  -  TimeRange distance(TimeRange to) -  { -  if (!to->is_stardate) -  error("distance: Incompatible type %O\n",to); -  if (to->tick<tick) -  error("negative distance\n"); -  return Tick("stardate",rules,tick,to->tick-tick); -  } -  -  array _compare(TimeRange with) -  { -  float b1=tick; -  float e1=tick+len; -  float b2,e2; -  if (with->is_stardate) -  b2=with->tick,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) }); +  jd=(float)day[0]; +  from_julian_day(jd);    }    -  int __hash() { return (int)tick; } -  -  cTick set_ruleset(Ruleset r) +  static void from_stardate(float f)    { -  return Tick("stardate",r,tick,len); +  tics=f; +  jd=f/TNGSTARPERJULIAN+2569518.5;    }    -  string _sprintf(int t) +  static void from_julian_day(float f)    { -  switch (t) -  { -  case 'O': -  if (len!=0.0) -  return sprintf("Tick(%s)",nice_print_period()); -  return sprintf("Tick(%s)",nice_print()); -  default: -  return 0; +  jd=f; +  tics=(f-2569518.5)*TNGSTARPERJULIAN;    } -  } +     -  string nice_print_period() -  { -  if (len>0.010) -  return sprintf("%s..%s",nice_print(),end()->nice_print()); -  else -  return sprintf("%s..%+g",nice_print(),len); -  } + //-- nonstandard methods --------------------------------------------    -  string nice_print() +  float number()    { -  return sprintf("%.3f",tick); +  return tics;    }    - //! string format_long() - //! string format_short() - //! string format_vshort() - //! Format the stardate tick nicely. - //! <pre> - //! long "-322537.312" - //! short "77463.312" (w/o >100000-component) - //! short "7463.312" (w/o >10000-component) - //! </pre> -  -  string format_long() +  int julian_day()    { -  return sprintf("%.3f",tick); +  return (int)jd;    }    -  string format_short() +  float julian_day_f()    { -  return sprintf("%.3f",tick-((int)tick/100000)*100000); +  return jd;    } -  -  string format_vshort() -  { -  return sprintf("%.3f",tick-((int)tick/10000)*10000); +    } - } -  - // compat - function(mixed...:cTick) TNGDate=cTick; -  - // for events - function(mixed...:cTick) Day=cTick; -  - //------------------------------------------------------------------------ - // global convinience functions - //------------------------------------------------------------------------ -  - //! method TimeofDay now() - //! Give the zero-length time period of the - //! current time. -  - TimeofDay now() - { -  return Tick(); - } +