]> git.phdru.name Git - m_lib.git/blobdiff - m_lib/opdate.py
Use print function for Py3 compatibility
[m_lib.git] / m_lib / opdate.py
index 13a9d253354d0f7dec2d7877f427b03b97dd79e3..b28dec67df4fe2e6a33a4baa493f6f6b80db1fd4 100755 (executable)
@@ -7,6 +7,7 @@
 #
 
 
+from __future__ import print_function
 from string import *
 from time import *
 from calendar import *
@@ -440,38 +441,39 @@ LongMonthNamesA = ['
 #
 
 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()