#
# ajd3.txt - ajmonth tests
# ========
# This script tests date offsetting by months  as well as the
# ability to set a date to the first and last day of the month.
#

#
# Set and verify the current date and time
#
ajsetdate 2011-07-15,15:00:00
ajformatdate PLAIN

#
# Null op test
#
ajmonth 0 KEEPDAY     # Date should still be the same 
ajformatdate PLAIN    # Expecting 2011-07-15 15:00:00

#
# Test element validation
#
ajmonth 0 KEEPDATE    # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-07-31 15:00:00
ajmonth 0 0           # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-07-31 15:00:00
ajmonth 0 32          # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-07-31 15:00:00

#
# Changing the day of the month in the same month
#
ajmonth 0 7           # Date should be 7th July
ajformatdate PLAIN    # Expecting 2011-07-07 15:00:00
ajmonth 0 FIRSTDAY    # Date should be 1st July
ajformatdate PLAIN    # Expecting 2011-07-01 15:00:00
ajmonth 0 LASTDAY     # Date should be 31st July
ajformatdate PLAIN    # Expecting 2011-07-31 15:00:00

#
# Changing the month, day of month unchanged
#
ajsetdate 2011-07-15,15:00:00
ajformatdate PLAIN
ajmonth 1 KEEPDAY     # Same day in August 
ajformatdate PLAIN    # Expecting 2011-08-15 15:00:00
ajmonth -6 KEEPDAY    # Same day in February 
ajformatdate PLAIN    # Expecting 2011-02-15 14:00:00 (summer->winter time)
ajmonth -2 KEEPDAY    # Same day in the previous December 
ajformatdate PLAIN    # Expecting 2010-12-15 14:00:00
ajmonth 7 KEEPDAY     # Back to the original date 
ajformatdate PLAIN    # Expecting 2011-07-15 15:00:00 (winter->summer time)

#
# Check truncation flag validation
#
ajtruncate ON         # Should be OK
ajtruncate OFF        # Should be OK
ajtruncate INCORRECT  # Should report an error

#
# Check that out of range days are caught and fixed
# after a month change, with truncation OFF 
#
ajtruncate OFF
ajsetdate 2011-07-30,15:00:00
ajformatdate PLAIN     # Expecting 2011-07-30 15:00:00
ajmonth -5 KEEPDAY     # Day out of range for February 
ajformatdate PLAIN     # Expecting 2011-03-02 15:00:00

#
# Check that out of range days are caught and fixed
# after a month change, with truncation ON 
#
ajtruncate ON
ajsetdate 2011-07-30,15:00:00
ajformatdate PLAIN     # Expecting 2011-07-30 15:00:00
ajmonth -5 KEEPDAY     # Day out of range for February 
ajformatdate PLAIN     # Expecting 2011-02-28 15:00:00

#
# Check combined operation
#
ajsetdate 2011-07-15,15:00:00
ajformatdate PLAIN     # Expecting 2011-07-15 15:00:00
ajmonth 1 LASTDAY      # Set last day of next month (August) 
ajformatdate PLAIN     # Expecting 2011-08-31 15:00:00
ajmonth -2 LASTDAY     # Set last day of June 
ajformatdate PLAIN     # Expecting 2011-06-30 15:00:00

#
# 4 errors expected
#
