man ua_date




NAME

  ua_date - Perform date subtraction and convert date/time formats


SYNOPSIS

  ua_date
         [-options] [date1 [date2]]


DESCRIPTION

  The  ua_date  accepts  input date(s) in various formats and can format output date-
  times in a defined format.

  In addition, ua_date can perform date subtraction and delta-time calculations which
  makes it useful for date-time comparisons.


ARGUMENTS

  date1  Date (or Date.Time) string to convert.  Defaults as "now".

  date2  If provided, date2 is subtracted from date1 to obtain a delta time.

         Date formats can be specified as:
                  yyyymmdd.hhmmss
                    yymmdd.hhmmss
                yyyy-mm-dd.hh:mm:ss
                yyyy/mm/dd.hh:mm:ss
                  yy/mm/dd.hh:mm:ss
                           hh:mm:ss
                     mm/dd.hh:mm
           [[[yy]yy]mm]dd[.[hh[mm[ss]]]]
                     yyjjj.hhmmss  (julian)
                [yy]yyjjj[.[hh[mm[ss]]]]
                        +d.hhmmss  (delta plus)
                        -d.hhmmss  (delta minus)
                          .        (assumed now)

         The  date  can  also  be  specified in C-time (seconds since 1970) as either
         dSeconds (decimal) or xSeconds (hex).

         Time is optional in all formats.  Date is optional if  colons  are  used  to
         specify the time.  When specifying days in the past, such as -1, if the time
         is not supplied ua_date assumes midnight is desired.  When  specifying  days
         in  the  future, such as +1, if the time is not supplied ua_date assumes the
         current time.

         Date argument examples (assuming now is 10 Sep 1997):
                 970910.1215     # 10 September, 12:15pm
                 97/09/10.12:15  #       (same)
                 910.12          # 10 September, Noon
                 9/10            # 10 September
                 10              #       (same)
                 .12:15,         # today,        12:15pm
                 -1              # one day ago
                 +.1             # one hour from now
                 -.1             # one hour ago


OPTIONS

  -normal
         "Normal" (default) display.

  -reset UNIX format for setting date.

  -seconds
         Display a time in seconds.

         For delta times or subtracted times this represents actual seconds.   For  a
         single time this represents seconds since midnight.

  -hours Dispaly a time in hours.

         For  delta  times  or  subtracted times this represents actual hours.  For a
         single time this represents hours since midnight.

  -days  Dispaly a time in days.

         For delta times or subtracted times this represents actual days.  For a sin-
         gle time this represents days since midnight.

  -ctime C time display (seconds since 1970) in hex and decimal.

  -format [field-descriptor...]
          Display date-time in specified format, such as:
             "%m/%d/%Y %H:%M:%S"
          would represent 09/10/1997 12:15:00.

  -all   Display all formats above

  -verbose
         To display additional debugging information

  -?     To display a terse help message


EXAMPLES

   # ua_date              # normal
   20080610.142414 yyyymmdd.hhmmss 2008-06-10 14:24:14 (2008.162)

   # ua_date -f %m/%d/%Y.%H:%M:%S # specified format
   06/10/2008.14:24:15

   # ua_date -all         # all formats
   20080610.142427 yyyymmdd.hhmmss 2008-06-10 14:24:27 (2008.162)
   unix 'date' 061014242008.27
    days>00:00         0.60
   hours>00:00        14.41
   mins.>00:00       864.45
   secs.>00:00     51867
   ctime(1970) 0x00000000484ef10b 1213133067

   # ua_date 314          # specified month and day
       0314.142438     mmdd.hhmmss 2008-03-14 14:24:38 (2008.074)

   # ua_date 3/14.12:15   # month, day, hour minute
       0314.121500     mmdd.hhmmss 2008-03-14 12:15:00 (2008.074)

   # ua_date +.1          # one hour from now
        0.0417 days : 2008-06-10 15:24:59 (2008.162)

   # ua_date -.1          # one hour ago
       -0.0417 days : 2008-06-10 13:24:59 (2008.162)

   # ua_date +1           # one day from now
        1.0000 days : 2008-06-11 14:24:59 (2008.163)

   # ua_date -1           # one day ago
       -1.6007 days : 2008-06-09 00:00:00 (2008.161)

  Note  above  going  back a day without specifying time goes back to midnight of the
  previous day.

   # ua_date -sec +.001817 # seconds in 18 min 17 sec
        1097

   # ua_date 5/14 4/14    # subtract two dates
       30.0000 days : 2008-05-14 14:24:59 (2008.135)

   # ua_date 3/14 4/14    # subtract two dates
      -31.0000 days : 2008-03-14 14:24:59 (2008.074)

   # ua_date 2/14 3/14    # subtract two again
      -28.9583 days : 2008-02-14 14:24:59 (2008.045)

  Note above that daylight savings time change occured between the dates so  an  hour
  less than 29 days (leap year) is reported.

  All  formats  for  45 days ago, note that options can be specified either before or
  after arguments:

   # ua_date -45 -a       # 45 days ago
      -45.6007 days : 2008-04-26 00:00:00 (2008.117)
   unix 'date' 042600002008.00
    days>00:00       -45.60
   hours>00:00     -1094.42
   mins.>00:00    -65664.98
   secs.>00:00  -3939899
   ctime(1970) 0x000000004812d2f0 1209193200

   # ua_date 0x7fffffff   # specify a hex ctime date
   20080610.142459 2038-01-18 19:14:07 (2038.018)

  Note, UNIX binary is seconds since 1970 (+/- timezone):
    the maximum signed 32bit date is 0x7fffffff or 01/18/2038
    the miniumn signed 32bit date is 0x80000000 or 12/13/1901

  The time_t declaration is signed.  Commercial 64bit systems became popular  in  the
  late  1990s, but well into the 2000s imbedded systems continued to use 32bit chips.
  Yes, there may be a real y32k problem in 2038 if everything is not 64bit or greater
  by then.  Can any 32bit imbedded systems survive that long?


RESTRICTIONS / NOTES

  ua_date  has  been  tested under DU v3.2g-v4.0d, IRIX 6.2-6.5, Unicos 10, Unicos/mk
  2.0, Solaris, AIX 5.1-5.3, and various Linux.

  This command utilizes the cci command parser utilized by non-UNIX operating systems
  instead  of  the  traditional  UNIX getopt() parsing.  Options have been defined to
  "look like" UNIX style options, but can be spelled out  or  generally  abbreviated.
  For  example  -n  is  the same as -normal.  In some cases, like ´-seconds´, options
  must be partially or fully spelled out.  Required option length  can  be  found  by
  ua_date  -?  .   Because  of  this multiple options must be space separated and the
  hyphen is part of the option name.


ACKNOWLEDGEMENTS

  Written at the University of Alaska.  Ongoing maintenance via SourceForge by Denali
  Sun Consulting.

  Suggestions or bug reports can be directed to denalisun907@gmail.com.


RELATED INFORMATION

  Commands: date(1).