RFC-Compliant Time Functions
Dealing with Time Strings on the NetSeveral formats for specifying dates and times are used in internet applications like SMTP and HTTP.
tcpcmd provides nine time conversion functions to help you deal with these various time formats.
These functions are in the interfaces table, but are documented separately here.
All rfc time verbs return a string or cause a script error if they can't convert the time contained in the parameter.
The syntax of the rfc time functions are:
tcpcmd.interfaces.rfcDateTo822 ([theDate])where
theDateis an optional parameter of typestringordate. The default is the current date and time. theDate is converted to a string conforming to RFC-822 convention. This is the format used by Eudora.Examples:
The GMT offset returned is that computed by using the Macintosh's current location and time settings.
tcpcmd.interfaces.rfcDateTo822 ()
« "Sun, 27 Oct 1996 12:16:54 -0500"tcpcmd.interfaces.rfcDateTo822 ("1/1/97; 2:00 AM")
« "Wed, 01 Jan 1997 02:00:00 -0500"
tcpcmd.interfaces.rfcDateTo850 ([theDate])where
theDateis an optional parameter of typestringordate. The default is the current date and time. theDate is converted to a string conforming to RFC-850 convention. The RFC's say this is now obsolete, but it quite common still.Example:
The time is adjusted to GMT using the Macintosh's current location and time settings.
pcmd.interfaces.rfcDateTo850 ()
« "Sunday, 27-Oct-96 17:55:26 GMT"
tcpcmd.interfaces.rfcDateToGMT ([theDate])where
theDateis an optional parameter of typestringordate. The default is the current date and time. Similar to RFC-850 format, the RFC's say this is the latest, preferred format.Example:
tcpcmd.interfaces.rfcDateToGMT ()
« "Sun, 27 Oct 1996 18:00:24 GMT"
tcpcmd.interfaces.rfcDateToString ([theDate] [,gmtOffset])where
theDateis an optional parameter of typestringordate. The default is the current date and time, andgmtOffsetis anumberrepresenting the number of seconds to use as the offset from GMT 0000 hours. The default gmtOffset is nil.
rfcDateToString returns a string with the same format as that returned by rfcDateToGMT.
The offset computed behaves like
mod(gmtOffset, 60), so gmtOffsets in increments of 60 are the only ones of consequence. If gmtOffset is omitted, then the current gmtOffset (as computed with the Macintosh's current location and time settings) is used.
This verb is useful for building time strings with a calculated GMT offset.
Examples:
>tcpcmd.interfaces.rfcDateToString ()
« "Sun, 27 Oct 1996 13:13:51 -0500"tcpcmd.interfaces.rfcDateToString (gmtOffset:3600)
« "Sun, 27 Oct 1996 13:14:35 +0100"tcpcmd.interfaces.rfcDateToString (gmtOffset:3660)
« "Sun, 27 Oct 1996 13:15:23 +0101"tcpcmd.interfaces.rfcDateToString (gmtOffset:7200)
« "Sun, 27 Oct 1996 13:16:26 +0200"
tcpcmd.interfaces.rfcGetCurrentDate ()Returns the current date and time in GMT format (as that returned by rfcDateToGMT).
Example:
tcpcmd.interfaces.rfcGetCurrentDate ()
« "Sun, 27 Oct 1996 13:25:13 -0500"
tcpcmd.interfaces.rfcGMTtoLocalString ([theDate] [,rfc850])where
theDateis an optional parameter of typestringordate. The default is the string produced by tcpcmd.interfaces.rfcLocalToGMTString () for the current date and time.rfc850is an optionalbooleanparameter which indicates whether to use RFC-850 format or not. The default isfalse.Examples:
Midnight, May 5th, 1996 in Greenwich, England was 7:00 PM US Eastern Time.
tcpcmd.interfaces.rfcGMTtoLocalString ()
« "Sun, 27 Oct 1996 13:26:30 -0500"tcpcmd.interfaces.rfcGMTtoLocalString (rfc850:true)
« "Sun, 27-Oct-19 13:26:30 -0500"tcpcmd.interfaces.rfcGMTtoLocalString ("5/5/96; 00:00 GMT")
« "Sat, 04 May 1996 19:00:00 -0500"
tcpcmd.interfaces.rfcLocalToGMTString() ([theDate])where
theDateis an optional parameter of typestringordate. The default is the string produced by tcpcmd.interfaces.rfcGetCurrentDate () for the current date and time.
Converts a date and time string or date value to GMT format, using the Macintosh's location and time settings to compute the GMT offset.
Example:
1:37 PM US Eastern time on Oct. 27, 1996 is 6:36 PM on the same day in Greenwich, England.
tcpcmd.interfaces.rfcLocalToGMTString ()
« "Sun, 27 Oct 1996 18:37:12 GMT"tcpcmd.interfaces.rfcStringToDate ([theDate])where
theDateis an optional parameter of typestringordate. The default is the current date and time.
Converts a date and time string such as those produced by the other tcpcmd rfc time verbs and returns a Frontier
datevalue.Example:
The value shown above is actually a string representation of the date stored in Frontier's internal date format. The value returned from rfcStringToDate is always a
tcpcmd.interfaces.rfcStringToDate ()
« "10/27/96; 5:04:47 PM"datevalue.
tcpcmd.interfaces.rfcStringToGMTDate ([theDate])where
theDateis an optional parameter of typestringordate. The default is the string produced by tcpcmd.interfaces.rfcDateTo822 () for the current date and time.
This verb converts a date and time string such as those produced by the tcpcmd rfc times verb to a GMT
datevalue.Example:
The value shown above is actually a string representation of the date stored in Frontier's internal date format. The value returned from rfcStringToDate is always a
tcpcmd.interfaces.rfcStringToGMTDate ()
« "10/27/96; 10:06:41 PM"datevalue.Restrictions
You must have your Macintosh Location and Date and Time Control Panel settings correct in order to get accurate time zone conversions in the rfc time verbs.
![]()
This page was last built on 8/1/98; 10:28:44 PM ET by Alan German, asg@erols.com. At the moment, I am using Macintosh OS to work on this website. The "Electric Cactus" graphic is based on original artwork owned by UserLand Software and is used with their permission.