#
# ajd4.txt - ajyear 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
#
ajyear 0 KEEPDATE     # Date should still be the same 
ajformatdate PLAIN    # Expecting 2011-07-15 15:00:00

#
# Changing the month in the same year
#
ajyear 0 FIRSTDAY     # Date should be 1st Jan
ajformatdate PLAIN    # Expecting 2011-01-01 14:00:00 (winter time)
ajyear 0 LASTDAY      # Date should be 31st Dec
ajformatdate PLAIN    # Expecting 2011-12-31 14:00:00 (winter time)

#
# Check error reporting
#
ajyear 0 KEEPDAY      # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-12-31 14:00:00
ajyear 0 0            # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-12-31 15:00:00
ajyear 0 15           # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-12-31 15:00:00
ajyear 0 32           # Throws error, date unchanged
ajformatdate PLAIN    # Expecting 2011-12-31 15:00:00

#
# Changing the year, month and day of month unchanged
#
ajsetdate 2011-07-15,15:00:00
ajformatdate PLAIN
ajyear 1 KEEPDATE     # Same date in 2012 
ajformatdate PLAIN    # Expecting 2012-07-15 15:00:00
ajyear -6 KEEPDATE    # Same date in 2006 
ajformatdate PLAIN    # Expecting 2006-07-15 15:00:00
ajyear -10 KEEPDATE   # Same date in 1996
ajformatdate PLAIN    # Expecting 1996-07-15 15:00:00
ajyear 15 KEEPDATE    # Back to the original date 
ajformatdate PLAIN    # Expecting 2011-07-15 15:00:00

#
# Check truncation of a leap year, truncation ON
#
ajtruncate ON
ajsetdate 2012-02-29,12:00:00
ajformatdate PLAIN    # Expecting 2012-02-29 12:00:00
ajyear -2 KEEPDATE    # Too many days for a non leap year
ajformatdate PLAIN    # Expecting 2010-02-28 12:00:00
 
#
# Check truncation of a leap year, truncation OFF
#
ajtruncate OFF
ajsetdate 2012-02-29,12:00:00
ajformatdate PLAIN    # Expecting 2012-02-29 12:00:00
ajyear -2 KEEPDATE    # Too many days for a non leap year
ajformatdate PLAIN    # Expecting 2010-03-01 12:00:00
 
#
# Check combined operation
#
ajsetdate 2011-07-15,15:00:00
ajformatdate PLAIN    # Expecting 2011-07-15 15:00:00
ajyear 1 LASTDAY      # Set last day of 2012 
ajformatdate PLAIN    # Expecting 2012-12-31 14:00:00 (winter time)
ajyear -3 FIRSTDAY    # Set first day of 2009 
ajformatdate PLAIN    # Expecting 2009-01-01 14:00:00 (winter time)

#
# Return to the original date
#
ajyear 2 KEEPDATE     # Back to 1st Jan, 2011
ajformatdate PLAIN    # Expecting 2011-01-01 14:00:00 (winter time)
ajmonth 6 15          # Roll forward 6 months and set the 15th 
ajformatdate PLAIN    # Expecting 2011-07-15 15:00:00 (summer time)

#
# 4 errors expected
#
