# opDate - date/time manipulation routines
# Some ideas came from Turbo Professional/Object Professional (t/o)pDate.PAS
#
-# Written by Broytman, Nov 1997 - Dec 2003
-# Copyright (C) 1997-2003 PhiloSoft Design
-#
+from __future__ import print_function
from string import *
from time import *
from calendar import *
#
def test():
- print "Is 1984 leap year?", IsLeapYear(1984)
- print "Is 1990 leap year?", IsLeapYear(1990)
+ print("Is 1984 leap year?", IsLeapYear(1984))
+ print("Is 1990 leap year?", IsLeapYear(1990))
- print "Days in month 8 year 1996:", DaysInMonth(8, 1996)
+ print("Days in month 8 year 1996:", DaysInMonth(8, 1996))
- print "Is date 8/12/1996 valid?", ValidDate(8, 12, 1996)
- print "Is date 40/11/1996 valid?", ValidDate(40, 11, 1996)
- print "Is date 8/14/1996 valid?", ValidDate(8, 14, 1996)
+ print("Is date 8/12/1996 valid?", ValidDate(8, 12, 1996))
+ print("Is date 40/11/1996 valid?", ValidDate(40, 11, 1996))
+ print("Is date 8/14/1996 valid?", ValidDate(8, 14, 1996))
- print "Date->DMY for 138219:", DateToDMY(138219)
+ print("Date->DMY for 138219:", DateToDMY(138219))
diff = DateDiff(DMYtoDate(12, 10, 1996), DMYtoDate(12, 10, 1997))
- print "Date 12/10/1996 and date 12/10/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0])
+ print("Date 12/10/1996 and date 12/10/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0]))
diff = DateDiff(DMYtoDate(12, 10, 1996), DMYtoDate(12, 11, 1997))
- print "Date 12/10/1996 and date 12/11/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0])
+ print("Date 12/10/1996 and date 12/11/1997 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0]))
diff = DateDiff(DMYtoDate(31, 1, 1996), DMYtoDate(1, 3, 1996))
- print "Date 31/01/1996 and date 01/03/1996 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0])
+ print("Date 31/01/1996 and date 01/03/1996 diff: %d years, %d months, %d days" % (diff[2], diff[1], diff[0]))
- #print "November is %dth month" % MonthStringToMonth("November")
+ #print("November is %dth month" % MonthStringToMonth("November"))
- print "Today is", Today()
- print "Now is", CurrentTime()
+ print("Today is", Today())
+ print("Now is", CurrentTime())
- print "My birthday 21 Dec 1967 is (must be Thursday):", day_name[DayOfWeekDMY(21, 12, 67)]
+ print("My birthday 21 Dec 1967 is (must be Thursday):", day_name[DayOfWeekDMY(21, 12, 67)])
gmt = DateTimeToGMT(DMYtoDate(21, 12, 1967), HMStoTime(23, 45, 0))
- print "21 Dec 1967, 23:45:00 --", gmtime(gmt) # DOS version of gmtime has error processing dates before 1/1/1970 :(
+ # DOS version of gmtime has error processing dates before 1/1/1970 :(
+ print("21 Dec 1967, 23:45:00 --", gmtime(gmt))
D, T = GMTtoDateTime(gmt)
- print "(gmt) --", DateToDMY(D), TimeToHMS(T)
+ print("(gmt) --", DateToDMY(D), TimeToHMS(T))
if __name__ == "__main__":
test()