tsdate - Write date difference or converted date to UNIX stdout

SYNOPSIS

tsdate  [ parameter=value ]

Parameters are: output, std_format, base_year, days_since, date, minus_date.

DESCRIPTION

tsdate is a tool intended for use in post-processing scripts. It can be used to compute the difference between two dates, or to convert from one date format to another. tsdate writes the result to UNIX stdout, which makes it easy to capture the result in a shell variable, e.g.,

    set DIFF = `tsdate output=diff date=$PASSDATE minus_date=$ORBDATE`

The functionality of tsdate is best illustrated by example. In the following C-shell examples, date parameters are supplied explicitly; in a script, they normally would be supplied implicitly by variable.

Difference between two dates; date and minus_date can be expressed in either yy/mm/dd or yy.ddd:

    % set DIFF = `tsdate output=diff date=96/09/25 minus_date=96/08/31`
    % echo $DIFF
    25

Convert date in (year, month, day) or (year, Julian day) to days since January 1, 1970, inclusive:

    % set DAYS = `tsdate output=since base_year=1970 date=71/2/14`
    % echo $DAYS
    410

    % set DAYS = `tsdate output=since base_year=1970 date=71.045`
    % echo $DAYS
    410

Convert days since January 1, 1970, inclusive, to (year, month, day) or (year, julian day):

    % set YMD = (`tsdate output=yy_mm_dd std_format=no
                                    base_year=1970 days_since=410`)
    % echo $YMD[1] $YMD[2] $YMD[3]
    71 02 14

    % set YYDDD = (`tsdate output=yy_ddd std_format=no
                                    base_year=1970 days_since=410`)
    % echo $YYDDD[1] $YYDDD[2]
    71 045

Convert (year, month, day) to/from (year, Julian day):

    % set YYDDD = ( `tsdate output=yy_ddd std_format=yes date=71/02/14` )
    % echo $YYDDD[1] $YYDDD[2]
    71 045

    % set YMD = ( `tsdate output=yy_mm_dd std_format=yes date=71.045` )
    % echo $YMD[1] $YMD[2] $YMD[3]
    71 02 14

PARAMETERS

output
This parameter specifies the output to generate. Valid reponses are [diff, since, yy_mm_dd, yy_ddd, yyyy_mm_dd, yyyy_ddd]. The default is diff. To summarize the examples above:

diff
Compute the difference between date and minus_date in days.
since
Convert date in either yy/mm/dd or yy.ddd to days since the base_year.
yy_mm_dd
Convert date in yy.ddd, or (base_year, days_since), to yy mm dd.
yy_ddd
Convert date in yy/mm/dd, or (base_year, days_since), to yy ddd.
yyyy_mm_dd
Convert date in yy.ddd, or (base_year, days_since), to yyyy mm dd.
yyyy_ddd
Convert date in yy/mm/dd, or (base_year, days_since), to yyyy ddd.
std_format
The parameter is used only when output=yy_mm_dd or output=yy_ddd. It specifies whether or not the date to be converted will be specified using the date parameter (standard TeraScan date format). Valid responses are [yes, no]. The default is yes.
base_year
This parameter is used only if output=since or std_format=no. If output=since, it specifies the base year for the output number of days. Otherwise, it specifies the base year for the days_since parameter. The valid range is [1900, 2100]. The default is 1900.
days_since
This parameter is used only if std_format=no. It specifies the number of days since January 1 of the base year, inclusive. (Inclusive means that January 1 of the base year corresponds to days_since=1). The valid range is any non-negative integer. There is no default.
date
This parameter is used when output=diff, output=since, or std_format=yes. When output=diff, it specifies the date to subtract from. Otherwise, it specifies the date to convert. date must be specified using either yy/mm/dd or yy.ddd formats. The default is today's date.
minus_date
When output=diff, this parameter specifies the date to subtract. It must be specified using either yy/mm/dd or yy.ddd formats. The default is today's date.

SEE ALSO

formats


Last Update: $Date: 2000/05/19 21:49:09 $