RE: Unix Time assistance


Subject: RE: Unix Time assistance
From: furbs (furbs@swjedi.net)
Date: Thu Apr 24 2003 - 13:10:27 AKDT


Alright, I got the script working to process the months and days. This is a
working script, that I have just been testing. It's a WSH script.

'==============================================================
the_days=56
the_month=null
month_array=Array(31,28,31,30,31,30,31,31,30,31,30,31)

for month_val = 0 to 11
 if the_days < month_array(month_val) then
  the_month = month_val + 1
  exit for
 else
  the_days = the_days - month_array(month_val)
  the_month = month_val + 1
 end if
next

if (the_days + 2) = (month_array((the_month-1))+1) then
 the_days = 1
else
 the_days = the_days + 2
end if

msgbox "the_month: "&the_month&" | the_days: "&the_days&""
'==============================================================

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

Quoting furbs <furbs@swjedi.net>:

>
> Alright, I think I figured it all out. However I would like some people to
> overlook it and see if there is something I may have missed. I'll draw the
> table I made up on paper here on how I processed the numbers: (hopefully this
>
> won't get jumbled after getting "bounced". It will require fixedsys font, or
>
> viewed in plain text:
>
> |-------------------------|
> | Original UNIX timestamp |--------------------------|
> | 1051154574 | mod 60 = seconds |
> |-------------------------| 54 |
> | div 60 = minutes |--------------------------|
> | 17519242 | mod 60 = minutes |
> |-------------------------| 22 |
> | div 60 = hours |--------------------------|
> | 291987 | mod 24 = hours |
> |-------------------------| 3 |
> | div 24 = total days |--------------------------|
> | 12166 | div 365.25 = years |
> |-------------------------| 33 + 1970 = 2003 |
> | mod 365.25 = days |--------------------------|
> | 112 | (div 30.5)+1 = months |
> |-------------------------| 4 |
> |--------------------------|
> | (mod 30.5)+3 = days |
> | 24 |
> |--------------------------|
> | 04-24-2003 03:22:54 |
> |--------------------------|
>
> The original date was "04-24-2003 12:22:54", so we add 9 hours to the 3 we
> got
> which makes sense because that is our time zone. I know that the days are
> averaged at 30.5, but I already have a script solution for that, someone want
>
> to check the logic though just to make sure?
>
> the_days = 112.75
> the_month = null
> month_array = Array(31,28,31,30,31,30,31,31,30,31,30,31)
> for month_val = 0 to 11
> if the_days < month_array(month_val) then
> the_month = month_val + 1
> exit for
> else
> the_days = the_days - month_array(month_val)
> the_month = month_val + 1
> end if
> next
> the_month = "The Month of course"
> the_days = "Now equals the day of the month"
>
>
>
>
> Brian ThunderEagle
> - http://www.swjedi.net
> - furbs@swjedi.net
> - bthundereagle@aidea.org
>
>
>
>
>
> Quoting "Hassler, Jeff" <Jeff.Hassler@asc.asrc.com>:
>
> >
> > Yes, I believe that does cover all the possibilities.
> >
> > -----Original Message-----
> > From: Larry Collier [mailto:larry@medease.com]=20
> > Sent: Wednesday, April 23, 2003 11:24 AM
> > To: Hassler, Jeff; aklug@aklug.org
> > Subject: RE: Unix Time assistance
> >
> > The one I use is:
> >
> > leap =3D (year mod 4 =3D 0) xor (year mod 100 =3D 0)
> > xor (year mod 400 =3D 0) xor (year mod 3600 =3D 0)
> >
> > Larry
> >
> > -----Original Message-----
> > From: aklug-bounce@aklug.org [mailto:aklug-bounce@aklug.org]On Behalf Of
> > Hassler, Jeff
> > Sent: Wednesday, April 23, 2003 6:43 AM
> > To: Larry Collier; aklug@aklug.org
> > Subject: RE: Unix Time assistance
> >
> >
> >
> > 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.=3D20
> >
> > 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]=3D20
> > 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 =3D3D 10585 for 70 & 71
> >
> > 10585 - (366 + 3 x 365) =3D3D 9124 for 72 to 75
> >
> > 9124 - 1461 =3D3D 7663 for 76 to 79
> > 7663 - 1461 =3D3D 6202 for 80 to 83
> > 6202 - 1461 =3D3D 4741 for 84 to 87
> > 4741 - 1461 =3D3D 3280 for 88 to 91
> > 3280 - 1461 =3D3D 1819 for 92 to 95
> > 1819 - 1461 =3D3D 358 for 96 to 99
> >
> >
> > 358 - 31 -29 -31 - 30 - 31 -30 -31 -31 -30 -31 -30 =3D3D 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 =3D3D 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 =3D3D 11315 days
> > > > 977616586 mod 86500 =3D3D 586 (new timestamp, only used for getting
> > below
> > > > results) 586 div 3600 =3D3D 0.1627 hours (0 hours)
> > > > 586 mod 3600 =3D3D 586 (new timestamp, only used for getting below
> > results)
> > > > 586 div 60 =3D3D 9.76 minutes (9 minutes)
> > > > 586 mod 60 =3D3D 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.
> >
>
>
>
> ---------
> 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 : Thu Apr 24 2003 - 14:12:49 AKDT