Пример #1
0
int
utime(const char *name, const struct utimbuf *times)
{
  struct DateStamp stamp;
  unsigned long days, secs;
  time_t time;

  if (times == NULL)
    DateStamp(&stamp);
  else {
    /*
     * AmigaDOS file date is the modification time
     */
    time = times->modtime;

    /*
     * Convert time (secs since 1.1.1970 GMT) to
     * AmigaDOS DateStamp (based on 1.1.1978 local time).
     */
    time -= __local_to_GMT; /* GMT to local */
    days = (unsigned long)time / (unsigned long)(24*60*60);
    secs = (unsigned long)time % (unsigned long)(24*60*60);
    stamp.ds_Days = (LONG)days;
    stamp.ds_Minute = (LONG)(secs / 60);
    stamp.ds_Tick = (LONG)((secs % 60) * TICKS_PER_SECOND);
  }

  if (!SetFileDate((STRPTR)name, &stamp)) {
    set_errno(IoErr());
    return -1;
  }

  return 0;
}
Пример #2
0
	TimeIt (STRPTR name) : Name(name)
	{
		fprintf(stdout, "Testing: %s...", name);
		fflush(stdout);

		DateStamp(&t1);
	}
Пример #3
0
bool my_utime (const TCHAR *name, struct mytimeval *tv) {

  struct DateStamp stamp;

  DebOut("name: %s\n", name);

  if(!tv) {
    /* get current time */
    struct DateTime dt;
    DateStamp(&dt.dat_Stamp);
    stamp.ds_Days   = dt.dat_Stamp.ds_Days;
    stamp.ds_Minute = dt.dat_Stamp.ds_Minute;
    stamp.ds_Tick   = dt.dat_Stamp.ds_Tick;
  }
  else {
    /* use supplied time */
    /* NOT TESTED! */
    struct mytimeval tv2;
    tv2.tv_sec = tv->tv_sec;
    tv2.tv_usec = tv->tv_usec;

    timeval_to_amiga (&tv2, &stamp.ds_Days, &stamp.ds_Minute, &stamp.ds_Tick);
  }

  DebOut("stamp.ds_Days: %d\n", stamp.ds_Days);
  DebOut("stamp.ds_Minute: %d\n", stamp.ds_Minute);
  DebOut("stamp.ds_Tick: %d\n", stamp.ds_Tick);

  return SetFileDate(name, &stamp);
}
Пример #4
0
clock_t clock(void)
{ struct DateStamp ds2;
  DateStamp(&ds2);
  return (((ds2.ds_Days-ds.ds_Days)*(24*60)+
           ds2.ds_Minute-ds.ds_Minute)*(60*TICKS_PER_SECOND)+
           ds2.ds_Tick-ds.ds_Tick)*CLOCKS_PER_SEC/TICKS_PER_SECOND;
}
Пример #5
0
static void
setGetentryGadgetsToEntry(Gui_t gui, Entry entry)
{
   struct DateStamp current;
   int windowOpen;

   get(gui -> getEntryWindowObject, MUIA_Window_Open, & windowOpen);
   if (! windowOpen) {
      set(gui -> getEntryWindowObject, MUIA_Window_Open, TRUE);
    }

   DateStamp(& current);
   if (entry == NULL) {
      set(gui -> geDate, MUIA_String_Contents, myDateToStr(& current));
      set(gui -> geTransaction, MUIA_String_Contents, "");
      set(gui -> geAmount, MUIA_String_Contents, "");
      set(gui -> geCheckNumber, MUIA_String_Contents, "");
      set(gui -> geImputation, MUIA_String_Contents, "");
      set(gui -> geReason, MUIA_String_Contents, "");
   }
   else {
      set(gui -> geDate, MUIA_String_Contents, myDateToStr(& entry -> date));
      set(gui -> geTransaction, MUIA_String_Contents, entry -> transaction);
      set(gui -> geAmount, MUIA_String_Contents, entry -> amount);
      set(gui -> geCheckNumber, MUIA_String_Contents, entry -> checkNumber);
      set(gui -> geImputation, MUIA_String_Contents, entry -> imputation);
      set(gui -> geReason, MUIA_String_Contents, entry -> reason);
   }
}
Пример #6
0
void timer_gettime(void *t, struct timeval *tv)
{
    if (tv) {
        struct DateStamp t;

        DateStamp(&t);
        tv->tv_sec = ((t.ds_Days + 2922) * 1440 + t.ds_Minute) * 60 + t.ds_Tick / TICKS_PER_SECOND;
        tv->tv_usec = (t.ds_Tick % TICKS_PER_SECOND) * 1000000 / TICKS_PER_SECOND;
    }
}
Пример #7
0
double dtime()
{
   struct   tt {
	long  days;
	long  minutes;
	long  ticks;
   } tt;

   DateStamp(&tt);
   return ((double)(tt.ticks + (tt.minutes * 60L * 50L))) / (double)HZ;
}
Пример #8
0
	~TimeIt ()
	{
		DateStamp(&t2);

		LONG ticks = t2.ds_Tick - t1.ds_Tick;
		LONG seconds = ticks / 50 + 60 * (t2.ds_Minute - t1.ds_Minute);
		if(ticks < 0)
			ticks += TICKS_PER_SECOND * 60;

		LONG spaces = 30-(12+strlen(Name));
		while(spaces-- > 0)
			fprintf(stdout, " ");

		fprintf(stdout, "%3d.%02d seconds\n", seconds, 2 * (ticks%50));
	}
Пример #9
0
SPDP dtime()
{
 SPDP q;

 struct tt
       {
	long  days;
	long  minutes;
	long  ticks;
       } tt;

 DateStamp(&tt);

 q = ((SPDP)(tt.ticks + (tt.minutes * 60L * 50L))) / (SPDP)HZ;

 return q;
}
Пример #10
0
void writelog(char *file, char *text) {
	BPTR fh;
	struct DateTime dt;
	char datebuf[14],timebuf[10],utbuf[100];
	DateStamp(&dt.dat_Stamp);
	dt.dat_Format = FORMAT_INT;
	dt.dat_Flags = 0;
	dt.dat_StrDay = NULL;
	dt.dat_StrDate = datebuf;
	dt.dat_StrTime = timebuf;
	DateToStr(&dt);
	sprintf(utbuf,"%s %s - %s\n",datebuf,timebuf,text);
	if(!(fh=Open(file,MODE_OLDFILE)))
		if(!(fh=Open(file,MODE_NEWFILE))) return;
	Seek(fh,0,OFFSET_END);
	FPuts(fh,utbuf);
	Close(fh);
}
Пример #11
0
int dtime(double p[])
{
 double q;

 struct tt {
	long  days;
	long  minutes;
	long  ticks;
 } tt;

 q = p[2];

 DateStamp(&tt);

 p[2] = ( (double)(tt.ticks + (tt.minutes * 60L * 50L)) ) / (double)HZ;
 p[1] = p[2] - q;
	
 return 0;
}
Пример #12
0
int main(void)
{
    struct AnchorPath aPath;
    struct RDArgs  *rda;
    IPTR            args[5] = { NULL, NULL, NULL, NULL, FALSE };
    struct DateTime dt;
    LONG            error = 0;
    BPTR            oldCurDir;
    LONG            retval = RETURN_OK;
    BOOL            timeError = FALSE; /* Error in time/date specification? */

    rda = ReadArgs("FILE/A,WEEKDAY,DATE,TIME,ALL/S", args, NULL);

    if(rda == NULL)
    {
	PrintFault(IoErr(), "SetDate");
	return RETURN_FAIL;
    }

    /* Use the current time as default (if no DATE, TIME or WEEKDAY is
       defined) */
    DateStamp(&dt.dat_Stamp);

    dt.dat_Flags   = DTF_FUTURE;
    dt.dat_Format  = FORMAT_DOS;
    dt.dat_StrDate = (TEXT *)args[ARG_DATE];
    dt.dat_StrTime = (TEXT *)args[ARG_TIME];

    /* Change the defaults according to the user's specifications */
    if(StrToDate(&dt))
    {
	dt.dat_StrDate = (TEXT *)args[ARG_WEEKDAY];

	if(!StrToDate(&dt))
	    timeError = TRUE;
    }
    else
	timeError = TRUE;
   
    if(timeError)
    {
	PutStr("SetDate: Illegal DATE or TIME string\n");
	return RETURN_FAIL;
    }


    aPath.ap_Flags = (BOOL)args[ARG_ALL] ? APF_DOWILD : 0;
    aPath.ap_BreakBits = SIGBREAKF_CTRL_C;
    aPath.ap_Strlen = 0;

    /* Save the current dir */
    oldCurDir = CurrentDir(NULL);
    CurrentDir(oldCurDir);

    error = MatchFirst((STRPTR)args[ARG_FILE], &aPath);

    while(error == 0)
    {
	CurrentDir(aPath.ap_Current->an_Lock);

	// VPrintf("%s", (IPTR *)&aPath.ap_Info.fib_FileName);
	
	SetFileDate(aPath.ap_Info.fib_FileName, &dt.dat_Stamp);

	error = MatchNext(&aPath);
    }
    
    MatchEnd(&aPath);

    /* Restore the current dir */
    CurrentDir(oldCurDir);
    
    FreeArgs(rda);

    if(error != ERROR_NO_MORE_ENTRIES)
    {
	if(error == ERROR_BREAK)
	    retval = RETURN_WARN;
	else
	    retval = RETURN_FAIL;

	PrintFault(IoErr(), "SetDate");
    }

    return retval;
}	
Пример #13
0
void __initclock(void)
{ DateStamp(&ds); }
Пример #14
0
int main(void)
{
    struct DateTime curr;
    char day[LEN_DATSTRING];
    char time[LEN_DATSTRING];
    char date[LEN_DATSTRING];
    struct DateStamp stamp;

    curr.dat_Format  = FORMAT_DOS;
    curr.dat_Flags   = 0;
    curr.dat_StrDay  = day;
    curr.dat_StrDate = date;
    curr.dat_StrTime = time;  

    DateStamp(&curr.dat_Stamp);
    DateToStr(&curr);
    Printf("Current time: %s, %s, %s\n", day, date, time);
    
    BPTR fh = Open("__TEST__", MODE_NEWFILE);
    
    if (fh != BNULL)
    {
        struct FileInfoBlock *fib = AllocDosObject(DOS_FIB, NULL);
        
        if (fib != NULL)
        {
            if (ExamineFH(fh, fib))
            { 
        	curr.dat_Stamp = fib->fib_Date;
        	DateToStr(&curr);
                Printf("File modification time: %s, %s, %s\n", day, date, time);
            }
            else
        	PrintFault(IoErr(), "Examine failed");

            Printf("Waiting 5 seconds\n");
            Delay(5*50);
            
            DateStamp(&stamp);
            
            Printf("Calling SetFileDate\n");
            if(SetFileDate("__TEST__", &stamp))
            {
                if (ExamineFH(fh, fib))
                { 
                    curr.dat_Stamp = fib->fib_Date;
                    DateToStr(&curr);
                    Printf("New file modification time: %s, %s, %s\n", day, date, time);
                }
                else
                    PrintFault(IoErr(), "Examine failed");        	
            }
            else
        	PrintFault(IoErr(), "SetFileDate");
            
            FreeDosObject(DOS_FIB, fib);
        }
        else 
            PrintFault(IoErr(), "Couldn't alloc FileInfoBlock");
            
        Close(fh);
        DeleteFile("__TEST__");
    }
    else
	PrintFault(IoErr(), "Couldn't create file");
    
    return 0;
}