import time,datetime def et(stamp=None): """Calculate Eorzea time from a UTC+0 Unixtimestamp. datetime.datetime.utcnow() is preferred, time.time() is not timezone neutral Returns a six-tuple containing year, month, day, hour, minute and seconds""" ratio = 20.571428571428573 utc = stamp epoch = datetime.datetime(year=2010, month=7, day=12, hour=0, minute=0, second=0) jptime = utc + (9*60*60) epoch = time.mktime(epoch.timetuple()) diff = jptime - epoch diff -= 90000 delta = (diff * ratio) gameSecond = int((delta % 60)) | 0 delta -= gameSecond delta /= 60.0 gameMinute = int((delta % 60)) | 0 delta -= gameMinute delta /= 60.0 gameHour = int((delta % 24)) | 0 delta -= gameHour delta /= 24.0 gameDay = int((delta % 32)) | 0 delta -= gameDay delta /= 32.0 gameMonth = int((delta % 12)) | 0 delta -= gameMonth delta /= 12.0 gameYear = int(delta) | 0 gameDay += 2 gameMonth += 1 gameMinute += 1 if gameMinute == 60: gameHour += 1 gameMinute = 0 if gameDay == 33: gameDay = 1 elif gameDay == 34: gameDay = 2 return(int(gameYear), int(gameMonth), int(gameDay), int(gameHour), int(gameMinute), int(gameSecond)) def eth(values=None): """Human-redable parser for eorzea.et. Returns a string that contains the current Eorzea hour, minute, second, along with the current date""" gameYear, gameMonth, gameDay, gameHour, gameMinute, gameSecond = values return("Eorzea time: %s:%s:%s (%s.%s.%s)" % ("0" + str(gameHour) if len(str(gameHour)) == 1 else gameHour, "0" + str(gameMinute) if len(str(gameMinute)) == 1 else gameMinute, "0" + str(gameSecond) if len(str(gameSecond)) == 1 else gameSecond, gameYear, "0" + str(gameMonth) if len(str(gameMonth)) == 1 else gameMonth, "0" + str(gameDay) if len(str(gameDay)) == 1 else gameDay))