slang-users mailing list

[2005 Date Index] [2005 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] TIme Routines.


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@xxxxxxxxx
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@xxxxxxxxxxxxxxxxxx> 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

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2005 date index] [2005 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]