C (20/304)

From:Jack York
Date:04 Aug 2000 at 01:01:43
Subject:Comparing dates

Hello,

I am trying to compare the date a file was written to todays date.
The code for todays date works fine but for the file, the date
is totally off (see below). The file used for this test was created
right before the program was ran so the dates should have been
the same, or close to it. Can anyone see where I am going wrong
or if there is a better way of doing this?

if ( clockdata = AllocVec(sizeof(struct ClockData), MEMF_FLAGS))
{
LONG currentday;

DateStamp(now);

currentday = SMult32(now->ds_Days, 86400) +
SMult32(now->ds_Minute, 60) +
SDivMod32(now->ds_Tick, TICKS_PER_SECOND);

Amiga2Date(currentday, clockdata);

printf("CURRENT %d %d %d %d hours %d mins %d secs\n",
clockdata->month, clockdata->wday,clockdata->year,
clockdata->hour,clockdata->min,clockdata->sec);

ExAll(obj_lock, buffer, SIZE_PATH, ED_TYPE, control);

if (ead->ed_Type < 1) //found a file
{
currentday = SMult32(ead->ed_Days, 86400) +
SMult32(ead->ed_Mins, 60) +
SDivMod32(ead->ed_Ticks,

TICKS_PER_SECOND);
Amiga2Date(currentday, clockdata);

printf("FILE DATE %d %d %d %d hours %d mins %d secs\n",
clockdata->month,clockdata->wday,clockdata->year,
clockdata->hour,clockdata->min,clockdata->sec);

result from printf's:

CURRENT 08 4 2000 19 hours 37 mins 11 secs
FILE DATE 9 0 2026 12 hours 27 min 55 secs

Jack