Contents of the NAVYTIME.DOC file
NAVYTIME -- Get Date/Time from Naval Observatory Page 1
Copyright 1987 Michael M Rubenstein
This software may be freely distributed as long as no fee is
assessed and the copyright notice is retained.
The functions contained in COMM.C, TIMER.C, and ATFINISH.C may be
distributed as part of an executable program (including
commercial distribution) provided the following copyright notice
Portions copyright 1987 Michael M Rubenstein
NAVYTIME calls the 1200 baud Naval Observatory time service for
digital clocks at (202) 653-0351 and sets the system time.
Because of delays in the phone system, the time may be off by as
much as .5 second.
Before using NAVYTIME certain things have to be set up. The
program must know the time zone and whether daylight savings time
is used. This is done by setting an environment variable TZ with
where xxx and yyy are any letters and n is the number of hours
behind Greenwich Mean time for standard time. If yyy is omitted,
the NAVYTIME assumes that daylight savings time is NOT used. xxx
and yyy are intended to be the abbreviation for the time used
(xxx for standard time, yyy for daylight savings time).
For example, if the area you are in uses Eastern Standard/Eastern
Daylight time, the command would be
(Eastern Standard is 5 hours behind GMT). If Eastern Standard is
used throughout the year, the command would be
Note that the number of hours behind GMT may be more than one
digit (in the Pacific) or may be negative (in most of Europe,
Africa, and Asia). The program, however, determines if Daylight
savings time is in effect based on the United States conventions.
It will also be necessary to modify the the configuration file,
NAVYTIME.RC. Users not in the Washington DC local calling area
will have to change the phone number on the second line to
include the area code. If your modem is not on COM1 or is not
NAVYTIME -- Get Date/Time from Naval Observatory Page 2
compatible with the Hayes 1200, other changes will be required.
The configuration file has a rather inflexible format. Each line
has a specific meaning. It is important that there be no spaces
at the ends of lines. The lines have the following meanings
1 The COM port to use. Only 1 and 2 are supported.
2 The command to initialize the modem and dial. It
consists of any combination of the following
- Strings in quotes which are sent to the
- Pairs of the form ^x where x is any
printing character which results in the
control character corresponding to x to be
sent. For example, to send a carriage
return, include the pair
- Integers which specify a delay in tenths of
a second. To pause one second include the
integer 10. Numbers larger than 3600 (if
your modem needs a delay any where close to
that, you have my deepest sympathy) will
not work properly.
- Any other characters, typically spaces,
which are ignored.
3 The command to send to terminate a call. This
line may be empty if the modem is configured to
disconnect when DTR is dropped.
4 The string to match to recognize establishment of
a connection. The modem must send a connection
message terminated by a carriage return or line
feed. A message containing this string in any
position (for example, NNEC will match CONNECT)
will be taken as indicating that the connection is
complete. Upper and lower case letters are
4-19 Up to 15 strings to match to recognize failure to
make a connection. These are matched in the same
way as the connect string.
An alternate configuration file for the Racal Vadic 2400V (and
possibly other Racal Vadic) modems is included as NAVYTIME.RV.
Finally, it is necessary to inform the program where the
NAVYTIME -- Get Date/Time from Naval Observatory Page 3
configuration file will be found. Normally, it assumes that the
configuration file will be C:\ETC\NAVYTIME.RC. If this is not
convenient, set the environment variable NAVYTIME to the full
name of the configuration file. For example, if the file will be
D:\CONFIG\NAVYTIME.CFG, use the command
If invoked with no parameters, NAVYTIME will call the time
service and set the DOS time, displaying no messages if
successful. If the command line parameter -v is given, the time
will be displayed. If the parameter -vv is given, modem messages
will also be displayed.
NAVYTIME does not set a battery backed up clock unless this is
done by MSDOS when the DOS time is set. To set a battery backed
up clock, invoke NAVYTIME with a batch file includes a command to
set the battery clock from the MSDOS time.
For the Hacker.
NAVYTIME is written in Turbo C. Since one of the reasons for
writing this program was to evaluate Turbo C, no attempt was made
to keep compatibility with other versions of C. Most other C
compilers will have difficulty with the prototype declarations
and the inline assembly code of comm.c.
Three files, COMM.C, TIMER.C, and ATFINISH.C will be of general
interest to Turbo C programmers.
COMM.C implements simple interrupt driven output, polled input to
COM1 and COM2. The main limitations are no checking for parity
or other errors and flow control is not implemented.
TIMER.C is a simple stopwatch timer. Because of MSDOS
limitations, timer completion must be polled with chk_timer().
ATFINISH is similar to the library function ATEXIT except that
the registered function will always be executed when the program
terminates (ATEXIT functions are executed only on normal
termination). Up to 8 functions may be registered.
These functions may be used for both free and commercial
distribution provided my copyright notice is included.
Commercial distributions may not include source or relocatables.