home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ivgate!oaminet!Michael.Groshart
- From: Michael.Groshart@oaminet.omahug.org (Michael Groshart)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Fun w/DateStamp
- Message-ID: <56.2a9abc1c@ivgate>
- Date: 25 Aug 92 01:09:09 CST
- Reply-To: michael.groshart@oaminet.omahug.org
- Organization: Omaha Amiga Net, Omaha
- Sender: news@ivgate.omahug.org (UUscan 1.10)
- Followup-To: comp.sys.amiga.programmer
- Lines: 79
-
- In a message of <23-Aug-92 16:34:03 > Paul Kienitz (11:30102/2) wrote:
-
- PK> (From: paulk@terapin.com (Paul Kienitz)) (Organization: BBS)
-
- >> I need to deduce the current date. DateStamp does the trick, of
- >> course, but how useful is the number of days since Jan. 1, 1978??? Does
- >> anyone know of a function or #define in the .h files somewhere that
- >> translates this cryptic "internal format" into something humans use?
-
- PK> Here is a sample function from a program of mine ... if the RawDoFmt
- PK> calls are confusing, just pretend that they are funny-looking
- PK> sprintf()s.
-
- (Paul's example deleted)
-
- This is another possible solution...
-
- /***************************************************************************/
-
- static void put_ch_proc(void)
- {
- #asm
- move.b d0,(a3)+
- #endasm
- }
-
- void raw_do_fmt(char *string,char *format, ...)
- {
- RawDoFmt(format,&format + 1,put_ch_proc,string);
- }
-
- /***************************************************************************/
-
- short days[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
- char months[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
- char datefmt[] = "%02d %.3s %04d %02d:%02d:%02d";
-
- #define LEAP(y) (!((y)%4)&&(((y)%100)||!((y)%400))) /* :-) */
-
- void stamp_to_str(struct DateStamp *stamp,char *string)
- {
- long xyzzy;
- short year,day,*d,hour,min,sec;
- char *month = months;
-
- xyzzy = (stamp->ds_Days + 1) * 100;
- year = (xyzzy / 36525) + 1978;
- day = (xyzzy % 36525 + 50) / 100;
-
- days[1] = 28 + LEAP(year); /* fudge factor */
-
- for (d = days ; *d < day ; d++)
- {
- day -= *d;
- month += 3;
- }
-
- hour = stamp->ds_Minute / 60;
- min = stamp->ds_Minute % 60;
- sec = stamp->ds_Tick / TICKS_PER_SECOND;
-
- raw_do_fmt(string,datefmt,day,month,year,hour,min,sec);
- }
-
- /***************************************************************************/
-
- Pass stamp_to_str() pointers to a DateStamp and string (22 chars) to
- receive the result.
-
-
- __
- ///
- __ /// Amiga Users of the Heartland
- \\\///
- \XX/ michael.groshart@hottub.omahug.org
- ---
- * Origin: "This Island Earth" -=*=- Omaha.NE.USA (1:285/30.52)
- SEEN-BY: 280/304 285/1 30 5010/1
-
-