X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_lib%2Fopdate.py;h=e6940a950f80817741213a98c40604ad7ec74b59;hb=74e8ff73da3efcb4e78358825b0d6b610197f721;hp=6d230860dcaa3c92d9be8897e04133e801260fd2;hpb=547baac5dc5c77a2f772a7b88101d434912fe1ce;p=m_lib.git diff --git a/m_lib/opdate.py b/m_lib/opdate.py index 6d23086..e6940a9 100755 --- a/m_lib/opdate.py +++ b/m_lib/opdate.py @@ -110,7 +110,7 @@ def DMYtoDate(Day, Month, Year): Year = Year - 1 Year = Year - MinYear - return (((Year / 100)*146097) / 4) + (((Year % 100)*1461) / 4) + (((153*Month)+2) / 5)+Day+First2Months + return (((Year // 100)*146097) // 4) + (((Year % 100)*1461) // 4) + (((153*Month)+2) // 5)+Day+First2Months def DateToDMY(Julian): @@ -128,11 +128,11 @@ def DateToDMY(Julian): Day = Julian-30 else: I = (4*(Julian-First2Months))-1 - J = (4*((I % 146097) / 4))+3 - Year = (100*(I / 146097))+(J / 1461) - I = (5*(((J % 1461)+4) / 4))-3 - Month = I / 153 - Day = ((I % 153)+5) / 5 + J = (4*((I % 146097) // 4))+3 + Year = (100*(I // 146097))+(J // 1461) + I = (5*(((J % 1461)+4) // 4))-3 + Month = I // 153 + Day = ((I % 153)+5) // 5 if Month < 10: Month = Month + 3 else: @@ -155,7 +155,7 @@ def IncDate(Julian, Days, Months, Years): Day = 28 Year = Year + Years - Year = Year + Months / 12 + Year = Year + Months // 12 Month = Month + Months % 12 if Month < 1: Month = Month + 12 @@ -181,7 +181,7 @@ def IncDateTrunc(Julian, Months, Years): Day = 28 Year = Year + Years - Year = Year + Months / 12 + Year = Year + Months // 12 Month = Month + Months % 12 if Month < 1: Month = Month + 12 @@ -273,9 +273,9 @@ def TimeToHMS(T): return 0, 0, 0 else: - Hours = T / SecondsInHour + Hours = T // SecondsInHour T = T - Hours*SecondsInHour - Minutes = T / SecondsInMinute + Minutes = T // SecondsInMinute T = T - Minutes*SecondsInMinute Seconds = T @@ -334,7 +334,7 @@ def RoundToNearestHour(T, Truncate = False): Seconds = 0 if not Truncate: - if Minutes >= (MinutesInHour / 2): + if Minutes >= (MinutesInHour // 2): Hours = Hours + 1 Minutes = 0 @@ -346,7 +346,7 @@ def RoundToNearestMinute(T, Truncate = False): Hours, Minutes, Seconds = TimeToHMS(T) if not Truncate: - if Seconds >= (SecondsInMinute / 2): + if Seconds >= (SecondsInMinute // 2): Minutes = Minutes + 1 Seconds = 0 @@ -387,7 +387,7 @@ def IncDateTime(DT1, Days, Secs): Secs = -Secs # adjust the date - DT2[0] = DT2[0] - Secs / SecondsInDay + DT2[0] = DT2[0] - Secs // SecondsInDay Secs = Secs % SecondsInDay if Secs > DT2[1]: @@ -403,7 +403,7 @@ def IncDateTime(DT1, Days, Secs): DT2[1] = DT2[1] + Secs # adjust date if necessary - DT2[0] = DT2[0] + DT2[1] / SecondsInDay + DT2[0] = DT2[0] + DT2[1] // SecondsInDay # force time to 0..SecondsInDay-1 range DT2[1] = DT2[1] % SecondsInDay