home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!ibmpcug!exnet2!flatlin!wolferts.ka.sub.org!dkw
- From: dkw@wolferts.ka.sub.org (Dr. Klaus Wolferts)
- Newsgroups: comp.bbs.waffle
- Subject: Re: STATUS File
- Message-ID: <XaceuB1w164w@wolferts.ka.sub.org>
- Date: Tue, 17 Nov 92 19:38:32 MEZ
- References: <gTXcuB7w165w@proteus.qc.ca>
- Distribution: world
- Organization: Ing'Buro f. EDV + Elektronik, D-7500 Karlsruhe 31
- Lines: 58
-
- randall@proteus.qc.ca (Randall Reid) writes:
-
- > ... I need to write a 4DOS batch file that will calculate the number
- > of seconds since Jan 1st 1970
- >
- > So far I figured out (by trial and error):
- >
- > seconds = %@eval[%@DATE[%_date]*24*60*60 (seconds between 1980 and today)
- > + %@time[%_time] (seconds since midnight)
- > + 315576000 (seconds between 1970-1980)
-
- There were 315532800 seconds from 1/1/70 to 1/1/80 (see below)
-
- > - 25200] (seconds in 7 hours)
- >
- > I used 365.25 * 10 * 24 * 60 *60 to compute the seconds from 1970-1980.
- > I'm not sure if this is entirely accurate considering leap years.
-
- More accurate (for your calculation) is (365 * 10 + 2) * 24 * 60 * 60
- for the 10 years, where the + 2 result from the two leap years '72 +'76.
- Your calculation would result in 3652.5 (!) days from 1/1/70 to 1/1/80!
- (Take the half day remaining for a super long sylvester party ;-)
-
- > The subtraction of 7 hours from the formula seems to yield the correct result
- > although I don't understand the significance of this number. I arrived at
- > it purely by emperical means.
- >
- > So, can someone tell me if and where I'm going wrong in this formula. I
- > can't help but think that the calculations for leap years must be more
- > complex.. perhaps requiring some modulo arithmetic. And I don't understand
- > why subtracting 7 hours seems to work.
-
- I don't know how exact the built in date and time calculations are,
- but taking the year with 365.25 days for day or date calculations will
- result in such errors you experienced.
-
- Thus the 7 hour subtraction yields the expected result for the months
- 3 to 12/92 only. You will get that correction values changing by
- +/- 6 hours = 0.25 days for every year, because calendar years last
- 365 or 366 days on leap years.
-
- You are quite right using modulo arithmetic for that purpose.
-
- For a little similiar problem (find the day of week (sun..sat = 0..6)
- out of day (1..31), month (1..12) and year (1..1999)), try do use
- the following (TPascal) formula:
-
- WeekDay:= (Year + Year Div 4 - Ord ((Month<=2) And (Year Mod 4 = 0))
- + Ord (Copy ('033614625035',Month,1)) + Day + 6) Mod 7;
- Klaus
-
-
- ____ __ __ __ __ __
- | \ | |/ / | | /| | / / Dr.-Ing. Klaus Wolferts: dkw@wolferts.ka.sub.org
-
- | | | | | / | |/ | |/ / Ing'Buro f. EDV + Elektronik
- | d| | | k| \ | w| /| | / Mitteltorstr. 45, Phone: +49 721 706016
- |____/ |__|\_\ |__|/ |__|/ D-7500 Karlsruhe 31, Germany, 49°03'02"N 8°22'58"E
-