[slang-users] TIme Routines.

Ben Duncan ben at versaccounting.com
Mon Jul 18 14:57:38 EDT 2005


Whoooa ... weird .... Slackware 10.1 but says libc-2.3.3-2.so ....

This was one That I did a "swaret" update on.

Maybe time to do a CD update ...

ANYWAY FWIW: I have gotten a hold of a DATE routine that will do days/dates
from Jan 1, 2000 baseline (a little more modern).
It based upon the SETI's RingLib routines. This will do days prior to  year 1582
and WAY out past 4000 A.D.

It is a fairly straight forward calculation routine and is not dependant
on any library.

When I get finished stripping it and converting it to my needs
(M/D/Y -> #(+/-) of days and #(+/-) of days to -> M/D/Y ) from baseline,
does anyone want me to post the program?


jmrobert5 at mchsi.com wrote:
> I don't know what to tell you.  But I also run Slackware 10.1, and I got similar
> results to John.  So its not inherit to Slackware per se.
> 
> I am running Slang 2.0.0 with the first patch.
> 
> Is your /lib/libc-2.3.4  ???  maybe it got changed/updated to something else?
> 
> A puzzler...
> --
> Joe Robertson
> jmrobert5 at mchsi.com
> http://home.mchsi.com/~jmrobert5/
> 
> 
> 
>>Slackware 10.1 .....glibc
>>
>>Ran your routine and got back a -1 from mktime ..
>>
>>John E. Davis wrote:
>>
>>>Ben Duncan <ben at versaccounting.com> wrote:
>>>
>>>
>>>>Anybody know of how to get mktime or has a routine to return
>>>>time values BEFORE the Epoch (12/31/1969).
>>>
>>>
>>>I have no problem with such values under Linux (debian woody, using
>>>glibc):
>>>
>>>  slsh> tm = localtime (-100000000);        
>>>  slsh> print (tm);
>>>  {tm_sec=20, tm_min=13, tm_hour=9, tm_mday=31, tm_mon=9, tm_year=66, 
>>
>>tm_wday=1, tm_yday=303, tm_isdst=0}
>>
>>>  slsh> mktime (tm);
>>>  -100000000
>>>
>>>What OS are you using?
>>>
>>>FWIW, here are some routines that I use to convert Unix time_t values
>>>to and from Julian dates:
>>>
>>>% This algorithm came from the calendar FAQ, and appears to have been derived
>>>% from "A Machine Algorithm for Processing Calendar Dates" 
>>>% by Fliegel and Flandern in Communications of the ACM from 1968.
>>>define tms_to_jd (tms)
>>>{
>>>   variable month = tms.tm_mon + 1;
>>>   variable a = (14 - month)/12;
>>>   variable y = (1900+tms.tm_year)+4800-a;
>>>   variable m = month + 12*a - 3;
>>>   variable day = tms.tm_mday;
>>>
>>>   variable jd = day + (153*m+2)/5 + y*365 + y/4 - y/100 + y/400 - 32045;
>>>   
>>>   % The julian day begins at noon
>>>   jd -= 0.5;
>>>   return jd + (tms.tm_hour + (tms.tm_min + tms.tm_sec/60.0)/60.0)/24.0;
>>>}
>>>
>>>define tms_to_mjd (tms)
>>>{
>>>   return tms_to_jd (tms) - 2400000.5;
>>>}
>>>
>>>
>>>define unix_to_mjd (t)
>>>{
>>>   return tms_to_mjd (gmtime (t));
>>>}
>>>
>>>define mjd_to_unix (mjd)
>>>{
>>>   variable t0 = 0;
>>>   variable t1 = 0x7FFFFFFFU;
>>>   variable mjd0 = unix_to_mjd (t0);
>>>   variable mjd1 = unix_to_mjd (t1);
>>>
>>>   if ((mjd0 > mjd) or (mjd > mjd1))
>>>     verror ("%S: date cannot be represented as a unix time_t", 
>>
>>_function_name);
>>
>>>   forever
>>>     {
>>>	variable t = t0 + (t1-t0)/2;
>>>	variable mjd2 = unix_to_mjd (t);
>>>
>>>	if (mjd2 <= mjd)
>>>	  {
>>>	     if (mjd2 == mjd)
>>>	       return t;
>>>
>>>	     mjd0 = mjd2;
>>>	     t0 = t;
>>>	     continue;
>>>	  }
>>>	mjd1 = mjd2;
>>>	t1 = t;
>>>     }
>>>}
>>>
>>>define mjd_to_year (mjd)
>>>{
>>>   variable t = mjd_to_unix (mjd);
>>>   variable tm = gmtime (t);
>>>   variable y = 1900.0 + tm.tm_year;
>>>   variable d = tm.tm_yday + (tm.tm_hour + 
>>
>>(tm.tm_min+tm.tm_sec/60.0)/60.0)/24.0;
>>
>>>   y += d/365.0;
>>>   return y;
>>>}
>>>
>>>
>>
>>-- 
>>Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
>>"Never attribute to malice, that which can be adequately explained by stupidity"
>>        - Hanlon's Razor
>>
>>
>>_______________________________________________
>>To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html
> 
> 

-- 
Ben Duncan   - VersAccounting Software LLC 336 Elton Road  Jackson MS, 39212
"Never attribute to malice, that which can be adequately explained by stupidity"
        - Hanlon's Razor





More information about the slang-users-l mailing list