#!/usr/bin/env perl
#=======================================================================
# name - tick
# purpose - Wrapper for tick subroutine in Manipulate_time.pm
#
# !Revision History
# 20110114  Stassi  Moved tick routine from script to Manipulate_time package
#=======================================================================
use strict;
use warnings;


# main program
#-------------
{
    use FindBin;
    use lib "$FindBin::Bin";
    use Manipulate_time "tick";
    my @result;

    usage() unless @ARGV;
    @result = tick @ARGV;
    print "@result\n";
}

#=======================================================================
# name - usage
# purpose - print usage information
#=======================================================================
sub usage {

  print <<"EOF";
NAME
     tick - Increments date and time

SYNOPSIS

     tick yyyymmdd
     tick yyyymmdd hhmmss
     tick yyyymmdd hhmmss isecs
     tick yyyymmdd hhmmss iyymmdd ihhmmss
     tick yyyymmdd hhmmss idays   ihhmmss -1
     tick yyyymmdd hhmmss iwwdd   ihhmmss -2

   where
     yyyymmdd = initial 8-digit date
     hhmmss   = initial 6-digit time

   increment values
     isecs   = number of seconds to add to initial date/time
     iyymmdd = date increment to add to initial date/time
     ihhmmss = time increment to add to initial date/time
     idays   = number of days to add to initial date/time
     iwwdd   = number of weeks and days to add to initial date/time

   flags
     -1 is flag indicating that 3rd parameter is idays rather than iyymmdd
     -2 is flag indicating that 3rd parameter is iwwdd rather than iyymmdd

DESCRIPTION
     Increments initial date/time (yyyymmdd/hhmmss) by isecs seconds,
     where isecs is specified directly as an integer number of seconds
     or indirectly as a time increment given by iyymmdd and ihms.

NOTES
   ! 1. Using the date increment (iyymmdd) to add months and years is not recommended
        since this will increment by generic 30-day months and 365-day years
     2. Increment values can be positive or negative
     3. tick will increment by 1 day if no increment values are specified
     4. All dates and times justify to the right; i.e. iyymmdd = 5
        is equivalent to iyymmdd = 000005 (date increment of 5 days)

EXAMPLES

     tick 20000228                  ===>   20000229         : add 1 day (no increments specified)
     tick 20000228 120000           ===>   20000229 120000  : add 1 day (no increments specified)

     tick 19990930 060000 36000     ===>   19990930 160000  : add 36000 secs = 10 hrs
     tick 19990930 060000 -36000    ===>   19990929 200000  : subtract 36000 secs
     tick 19990930 060000 5 0       ===>   19991005 060000  : add 5 days
     tick 19990930 060000 -5 0      ===>   19990925 060000  : subtract 5 days
     tick 19990930 060000 5 030000  ===>   19991005 090000  : add 5 days + 3 hours
     tick 19990930 060000 0 -120000 ===>   19990929 180000  : subtract 12 hours
     tick 19990930 060000 1 -120000 ===>   19990930 180000  : add 1 day - 12 hours

     tick 20130526 120000 105       ===>   20130526 120145  : add 105 secs
     tick 20130526 120000 105 0     ===>   20130630 120000  : add 1 month + 5 days = 35 days
     tick 20130526 120000 105 0 -1  ===>   20130908 120000  : add 105 days
     tick 20130526 120000 105 0 -2  ===>   20130607 120000  : add 1 week + 5 days = 12 days


AUTHOR
     Arlindo da Silva, dasilva\@dao.gsfc.nasa.gov

EOF

exit(1);
}
