RE: Unix Time assistance


Subject: RE: Unix Time assistance
From: furbs (furbs@swjedi.net)
Date: Wed Apr 23 2003 - 10:07:48 AKDT


I think I got the days figured out, but think there are still some issues with
the time. But here is what I got for converting the days. I tried this with 2
different sets, here is the first one:

Lets say we already narrowed it down to 11315 days since 01-01-1970.

11315 div 365.25 + 1970 = 2000 years
11315 mod 365.25 = 357.5 (new working unit)
(357.5 div 30.5) + 1 = 12 months
(357.5 mod 30.5) + 2 = 24 days

So we have 12-24-2000, which is the original date I was trying to get. Then I
tried another random date at 12165 days:

12165 div 365.25 + 1970 = 2003
12165 mod 365.25
(111.75 div 30.5) + 1 = 4
(111.75 mod 30.5) + 2 = 22

I have a reverse process that seems to be working to, if I want to convert a
regular date to a unix date. But still, i'm not 100% on the times yet. I may
have just made a mistake somewhere though.

     Brian ThunderEagle
      - http://www.swjedi.net
      - furbs@swjedi.net
      - bthundereagle@aidea.org

Quoting "Hassler, Jeff" <Jeff.Hassler@asc.asrc.com>:

>
> I've been trying to remember the leap year algorithm. I had to do this
> in c once to calculate the number of days between dates.=20
>
> I believe it is a leap year if evenly divisible by 4, except when not
> evenly divisible by 400 -- so 2000 was a leap year, but 1900 was not.
>
> Maybe this will help, or is just off the track.
>
> -----Original Message-----
> From: Larry Collier [mailto:larry@medease.com]=20
> Sent: Tuesday, April 22, 2003 6:20 PM
> To: aklug@aklug.org
> Subject: RE: Unix Time assistance
>
>
> DIVIDING BY 365.25 leads to small date errors (1 to 2 days). I use that
> to
> figure ages for display. I think you might do better to just count
> years.
> 1970 and 71 are 365, 72 is 366, etc. Depending on the range of dates
> you
> need to convert, this is easier thatn the research to find an ironclad
> method. When your down to less than a year use a short table to find
> the
> month. The day of the month is whats left.
>
>
> 11315 - 365 x 2 =3D 10585 for 70 & 71
>
> 10585 - (366 + 3 x 365) =3D 9124 for 72 to 75
>
> 9124 - 1461 =3D 7663 for 76 to 79
> 7663 - 1461 =3D 6202 for 80 to 83
> 6202 - 1461 =3D 4741 for 84 to 87
> 4741 - 1461 =3D 3280 for 88 to 91
> 3280 - 1461 =3D 1819 for 92 to 95
> 1819 - 1461 =3D 358 for 96 to 99
>
>
> 358 - 31 -29 -31 - 30 - 31 -30 -31 -31 -30 -31 -30 =3D 23
>
> gives dec 23, 2000
>
> Maybe I've got a boundary problem, but you get the idea.
>
> I have a formula to determine leap years accurate over at least half a
> million years if you need it.
>
> Larry
>
> Oh, I just realized the time value is for the next day.
>
> Got to go.
>
>
> -----Original Message-----
> From: aklug-bounce@aklug.org [mailto:aklug-bounce@aklug.org]On Behalf Of
> furbs
> Sent: Tuesday, April 22, 2003 3:06 PM
> To: Joshua J.Kugler
> Cc: aklug@aklug.org
> Subject: Re: Unix Time assistance
>
>
>
> Yes, the method below is incorrect. I can figure out the time, and the
> days
> are
> 11315. I just need to figure out how to convert that number into a date.
> To
> make up for leap years, its "days div 365.25 =3D years+1970". The part I
> can't
> figure out now is the month and day of month. Ideas?
>
>
>
> Brian ThunderEagle
> - http://www.swjedi.net
> - furbs@swjedi.net
> - bthundereagle@aidea.org
>
>
>
>
>
> Quoting "Joshua J.Kugler" <isd@as.uaf.edu>:
>
> >
> > But you have to keep in mind leap years and all that, so there is
> going to
> > have to be multiple cases when you're going from Unix time to "normal"
> > time.
> >
> > j----- k-----
> >
> > On Tuesday 22 April 2003 13:56, furbs wrote:
> > > I figured it out...kinda. I'm getting close enough to where I think
> I
> can
> > > get this figured out. Heres the basic outline:
> > >
> > > We have Unix timestamp, "977616586"
> > > which is supposed to be, "Dec 24 00:09:46 2000"
> > >
> > > 977616586 div 86400 =3D 11315 days
> > > 977616586 mod 86500 =3D 586 (new timestamp, only used for getting
> below
> > > results) 586 div 3600 =3D 0.1627 hours (0 hours)
> > > 586 mod 3600 =3D 586 (new timestamp, only used for getting below
> results)
> > > 586 div 60 =3D 9.76 minutes (9 minutes)
> > > 586 mod 60 =3D 46 seconds
> > >
> > > so we have: "11315 00:09:46" all thats left is figuring out the
> date,
> > which
> > > is what I am still working on.
> > --
> > Joshua Kugler, Information Services Director
> > Associated Students of the University of Alaska Fairbanks
> > isd@asuaf.org, 907-474-7601
> >
> > ---------
> > To unsubscribe, send email to <aklug-request@aklug.org>
> > with 'unsubscribe' in the message body.
> >
>
>
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>
>
> ---------
> To unsubscribe, send email to <aklug-request@aklug.org>
> with 'unsubscribe' in the message body.
>

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Wed Apr 23 2003 - 11:10:15 AKDT