UNSAFE MODULEDatePosix EXPORTSDate ; IMPORT Scheduler, Time, Date, DatePosix, Utime; REVEAL TimeZone = BRANDED "Date.TimeZone" REF INTEGER; CONST Unknown = "[Unknown zone]"; CONST GMT = "GMT"; PROCEDUREFromTime (t: Time.T; z: TimeZone := NIL): Date.T = VAR d: DatePosix.T; BEGIN Scheduler.DisableSwitching(); DatePosix.FromTime(t, z, d, Unknown, GMT); Scheduler.EnableSwitching(); RETURN Date.T{day := d.day, hour := d.hour, minute := d.minute, month := VAL(d.month, Month), offset := d.offset, second := d.second, weekDay := VAL(d.weekDay, WeekDay), year := d.year, zone := d.zone}; END FromTime; PROCEDUREToTime (READONLY d: T): Time.T RAISES {Error} = VAR t: Time.T; BEGIN Scheduler.DisableSwitching(); t := DatePosix.ToTime(DatePosix.T{day := d.day, hour := d.hour, minute := d.minute, month := ORD(d.month), offset := d.offset, second := d.second, weekDay := ORD(d.weekDay), year := d.year, zone := d.zone}); Scheduler.EnableSwitching(); IF t = -1.0d0 THEN RAISE Error END; RETURN t; END ToTime; BEGIN Scheduler.DisableSwitching(); Utime.tzset (); (* initialize Utime's global variables *) Scheduler.EnableSwitching(); Local := NEW(TimeZone); Local^ := 0; UTC := NEW(TimeZone); UTC^ := 1; DatePosix.TypeCheck(DatePosix.T{year := 1, month := 2, day := 3, hour := 4, minute := 5, second := 6, offset := 7, zone := LOOPHOLE(8, TEXT), weekDay := 9}, BYTESIZE(DatePosix.T)); END DatePosix.