FSTimeImpl.mesa
Last Edited by: Schroeder, November 15, 1983 1:37 pm
Last Edited by: Levin, August 9, 1983 11:36 am
DIRECTORY
Ascii USING [Lower],
BasicTime USING [GMT, Pack, Unpacked],
FSRemoteFile,
Rope USING [Fetch, ROPE];
FSTimeImpl: CEDAR MONITOR
IMPORTS Ascii, BasicTime, Rope
EXPORTS FSRemoteFile
= BEGIN
Time format is DD-MMM-YYbHH:MM:SSbZZT
Note that the leading digit in DD and HH may be replaced with a b
Exported to FSRemoteFile
FTPTimeToGMT: PUBLIC PROC [t: Rope.ROPE] RETURNS [BasicTime.GMT] =
BEGIN
Digit: PROC [index: INT] RETURNS [CARDINAL] =
BEGIN
c: CHAR = Char[index];
RETURN [ IF c = ' THEN 0 ELSE c - '0 ];
END;
Char: PROC [index: INT] RETURNS [CHAR] =
BEGIN
RETURN [ Ascii.Lower[ Rope.Fetch[t, index] ] ];
END;
uT: BasicTime.Unpacked;
uT.day ← Digit[0]*10 + Digit[1];
uT.year ← Digit[7]*10 + Digit[8] + 1900;
IF uT.year <= 1950 THEN uT.year ← uT.year + 1000;
uT.hour ← Digit[10]*10 + Digit[11];
uT.minute ← Digit[13]*10 + Digit[14];
uT.second ← Digit[16]*10 + Digit[17];
uT.month ← SELECT Char[3] FROM
'j => IF Char[4] = 'a THEN January
ELSE IF Char[5] = 'n THEN June ELSE July,
'f => February,
'm => IF Char[5] = 'r THEN March ELSE May,
'a => IF Char[4] = 'p THEN April ELSE August,
's => September,
'o => October,
'n => November,
'd => December,
ENDCASE => ERROR;
uT.zone ← 60 * ( SELECT Char[19] FROM
'e => 5,
'c => 6,
'm => 7,
'p => 8,
'+ => Digit[20],
'- => - Digit[20],
ENDCASE => ERROR ) ;
uT.dst ← IF (Char[20] = 'd) THEN yes ELSE no;
RETURN [BasicTime.Pack[uT]];
END;
END.