Closed BonnieToGamer closed 4 years ago
It's worth looking into unix time to understand this a bit better.
expiry_date = token_json['expiryDate'][:-4]
# Assumes the date is formatted like "2020-08-12 17:48:22".
unix_time = time.mktime(datetime.datetime.strptime(expiry_date, "%Y-%m-%d %H:%M:%S").timetuple())
All this does is to read the expiry date on the token previously generated and covert it to unix time (seconds since 1970, which is easier to do calculations on). With that unix time I calculate if the token is expired and if it is I generate a new one.
if time.time() + 5*60 > unix_time:
basically says if the current time + 5 minutes is over the expiry date of the token.
The schoolsoft calendar api is requested by entering a time range, unix_time_start and unix_time_end. The time range is based on unix time in milliseconds (unix time 1000).
`unix_time_end = (time.time() + 2592000)1000basically means: the end time is the current time + one month (
606024*30`)
Note that I round both start and end to avoid using decimals, that'll throw errors from the api.
thank you, i knew what unix time was i just didn't understand the code itself
Is any code still unclear or should I close this?
sorry forgot to close this
found in get_updated_token()
Found in get_calendar()
I'm trying to convert this API into C# and can't figure out what this is used for.