1985年生まれの暮らし方

日々の暮らしを記録しておこうかなと

GPS時刻→JST変換コード(Python)

print("Please input gps-time")
gps_time = int(input())-18+(3600*9) #うるう秒は18秒で計算、UTC+9hrに変換。
roll_over = gps_time // (1024*7*24*60*60)
week_time = gps_time - (roll_over*1024*7*24*60*60)
week_number = week_time // (7*24*60*60)
day_time = week_time - (week_number*7*24*60*60)
day = day_time // (24*60*60)
time = day_time - (day*24*60*60)
hr = time // (60*60)
min_time = time-(hr*60*60)
min2 = min_time // 60
sec = min_time - min2*60

print("roll_over : " + str(roll_over))
print("week_number : " + str(week_number))
print("day : " + str(day))
print("time(JST) : " + str(hr).zfill(2) + ":" + str(min2).zfill(2) + ":" + str(sec).zfill(2))