home *** CD-ROM | disk | FTP | other *** search
-
- #include <dos/datetime.h>
- #include <proto/dos.h>
-
- #include <string.h>
- #include <stdlib.h>
-
- extern struct DosLibrary *DOSBase;
-
- /* SMAKE */
-
-
- // DateToSeconds:
- //
- // Wandelt beliebigen Datums-String in Sekunden seit 1.1.1978 um.
- // Kennt bisher die folgenden Formate:
- //
- // 0 1 2
- // 012345678901234567890
- //
- // "01 Jan 91 11:22:33" Fido Standard DF_FIDO
- // "01 Jan 91 11:22" Fido Standard ohne Sekunden
- // "Wed 13 Jan 86 02:34" Fido SEAdog
- // "JJMMTThhmm" Z-Netz DF_ZNETZ
- // "01-Jan-78 10:11:12" AmigaDOS DF_ADOS
- // "01.01.78 10:11:12" AmigaDOS, Style Guide German, leading 0s
- // "1.1.78 10:11:12" AmigaDOS, Style Guide German
-
-
- LONG DateToSeconds(UBYTE *misc)
- {
- #define space(x) (misc[x]==' ')
- #define point(x) (misc[x]=='.')
-
- int len = misc ? strlen(misc) : 0;
- UBYTE dbuf[10] = "01-Jan-78";
- UBYTE tbuf[10] = "00:00:00";
- struct DateTime dt = { {0,0,0},FORMAT_DOS,0,NULL,NULL,NULL };
-
- dt.dat_StrDate = dbuf;
- dt.dat_StrTime = tbuf;
-
- if (len>=19 && space(2) && space(6) && space(9) && space(10))
- {
- // Standard Fido
-
- dbuf[0]=misc[0];
- dbuf[1]=misc[1];
- dbuf[3]=misc[3];
- dbuf[4]=misc[4];
- dbuf[5]=misc[5];
- dbuf[7]=misc[7];
- dbuf[8]=misc[8];
-
- tbuf[0]=misc[11+0];
- tbuf[1]=misc[11+1];
- tbuf[3]=misc[11+3];
- tbuf[4]=misc[11+4];
- tbuf[6]=misc[11+6];
- tbuf[7]=misc[11+7];
- }
- else if (len>=16 && space(2) && space(6) && space(9) && space(10))
- {
- // Standard Fido ohne Sekunden
-
- dbuf[0]=misc[0];
- dbuf[1]=misc[1];
- dbuf[3]=misc[3];
- dbuf[4]=misc[4];
- dbuf[5]=misc[5];
- dbuf[7]=misc[7];
- dbuf[8]=misc[8];
-
- tbuf[0]=misc[11+0];
- tbuf[1]=misc[11+1];
- tbuf[3]=misc[11+3];
- tbuf[4]=misc[11+4];
- }
- else if (len>=19 && space(3) && space(6) && space(10) && space(13))
- {
- // SEAdog
-
- dbuf[0]=misc[4+0];
- dbuf[1]=misc[4+1];
- dbuf[3]=misc[4+3];
- dbuf[4]=misc[4+4];
- dbuf[5]=misc[4+5];
- dbuf[7]=misc[4+7];
- dbuf[8]=misc[4+8];
-
- tbuf[0]=misc[14+0];
- tbuf[1]=misc[14+1];
- tbuf[3]=misc[14+3];
- tbuf[4]=misc[14+4];
- }
- else if (len==10)
- {
- // Z-Netz
-
- dt.dat_Format = FORMAT_CDN; // (dd-mm-yy)
-
- dbuf[0]=misc[4];
- dbuf[1]=misc[5];
- dbuf[2]='-';
- dbuf[3]=misc[2];
- dbuf[4]=misc[3];
- dbuf[5]='-';
- dbuf[6]=misc[0];
- dbuf[7]=misc[1];
- dbuf[8]=0;
-
- tbuf[0]=misc[6];
- tbuf[1]=misc[7];
- tbuf[3]=misc[8];
- tbuf[4]=misc[9];
- }
- else if (len>=8 && point(2) && point(5))
- {
- // AmigaDOS, Style Guide German, leading 0s [kmel]
-
- dt.dat_Format = FORMAT_CDN; // (dd-mm-yy)
-
- dbuf[0]=misc[0];
- dbuf[1]=misc[1];
- dbuf[2]='-';
- dbuf[3]=misc[3];
- dbuf[4]=misc[4];
- dbuf[5]='-';
- dbuf[6]=misc[6];
- dbuf[7]=misc[7];
- dbuf[8]=0;
-
- if (len >= 16)
- {
- tbuf[0]=misc[9+0];
- tbuf[1]=misc[9+1];
- tbuf[3]=misc[9+3];
- tbuf[4]=misc[9+4];
- tbuf[6]=misc[9+6];
- tbuf[7]=misc[9+7];
- }
- }
- else if (len>=6 && ((point(1) && point(3)) || (point(1) && point(4)) || (point(2) && point(4)) ))
- {
- // AmigaDOS, Style Guide German [kmel]
-
- WORD spos, dpos;
-
- dt.dat_Format = FORMAT_CDN; // (dd-mm-yy)
-
- spos = dpos = 0;
-
- if (point(spos+1))
- {
- dbuf[dpos++]='0';
- dbuf[dpos++]=misc[spos++];
- }
- else
- {
- dbuf[dpos++]=misc[spos++];
- dbuf[dpos++]=misc[spos++];
- }
- spos++;
- dbuf[dpos++]='-';
-
- if (point(spos+1))
- {
- dbuf[dpos++]='0';
- dbuf[dpos++]=misc[spos++];
- }
- else
- {
- dbuf[dpos++]=misc[spos++];
- dbuf[dpos++]=misc[spos++];
- }
- spos++;
- dbuf[dpos++]='-';
-
- dbuf[dpos++] = misc[spos++];
- dbuf[dpos++] = misc[spos++];
- dbuf[dpos] = 0;
-
- if (len > spos++)
- {
- tbuf[0]=misc[spos+0];
- tbuf[1]=misc[spos+1];
- tbuf[3]=misc[spos+3];
- tbuf[4]=misc[spos+4];
- tbuf[6]=misc[spos+6];
- tbuf[7]=misc[spos+7];
- }
- }
- else
- {
- // Unbekanntes Format, AmigaDOS soll sein Glück probieren
-
- char *x;
-
- if (x=strstr(misc,"day ")) misc=x+4;
-
- strncpy(dbuf,misc,9); // Die ersten 9 Zeichen sind Datum
-
- if ((x=strchr(misc,':')) && (UBYTE *)x>=misc+2)
- {
- strncpy(tbuf,x-2,8); // 2 Zeichen vor dem ersten : ist die Zeit
- }
- }
-
- // printf("Date: '%s' Time: '%s'\n", dbuf, tbuf);
-
- if (StrToDate(&dt))
- return((dt.dat_Stamp.ds_Days*24*60+dt.dat_Stamp.ds_Minute)*60+dt.dat_Stamp.ds_Tick/TICKS_PER_SECOND);
- else
- return(0);
- }
-
-
- LONG CurrentSeconds(VOID)
- {
- struct DateStamp ds;
-
- if (DateStamp(&ds))
- {
- return((ds.ds_Days*24*60+ds.ds_Minute)*60+ds.ds_Tick/TICKS_PER_SECOND);
- }
- return(0);
- }
-