Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highscore Date is in US Format - change it to ISO 8601 #9

Closed
ThomasChr opened this issue Feb 4, 2020 · 3 comments
Closed

Highscore Date is in US Format - change it to ISO 8601 #9

ThomasChr opened this issue Feb 4, 2020 · 3 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@ThomasChr
Copy link
Contributor

ThomasChr commented Feb 4, 2020

Highscore Dates look like this:

{ dreamlo: { leaderboard: { entry: [{ date: 2/4/20207: 28: 55AM, name: Nick, score: 106, seconds: 0, text: }, { date: 2/4/20207: 28: 47AM, name: Dario, score: 105, seconds: 0, text: }] } } }

Nobody likes the US Date Format, would be better if we stick to ISO 8601, which would be:

2020-02-04 08:28:55

-> Also account for the right timzeone (we seem to be one hour more than dreamlo.com) and for the 24 hours time format (no one likes AM/PM).

Godot does not seem to have date functions, so this could be a tough nut!

@ThomasChr ThomasChr changed the title Highscore Date is in US Format Highscore Date is in US Format - change it to ISO 8601 Feb 4, 2020
@ThomasChr ThomasChr added the good first issue Good for newcomers label Feb 4, 2020
@PyDario PyDario self-assigned this Feb 4, 2020
@ChLah
Copy link
Collaborator

ChLah commented Feb 5, 2020

@DDTyphos
As a first simple and naive approach you can use this.
I think, if Dreamlo doesn't change it's format, this will work fair enough.
Nevertheless, you should implement error handling and maybe also convert the time to the user's timezone (if Godot can provide it to you?)

	var date = "2/4/2020 8:45:06 AM"
	var splitup = date.split(" ", false, 0)
	var dateParts = splitup[0].split("/", false, 0)
	var timeParts = splitup[1].split(":", false, 0)
	var isPm = splitup[2] == "PM"
	
	var hour = int(timeParts[0])
	if isPm:
		hour = (hour + 12) % 24
	
	var paramsInOrder = [
		int(dateParts[1]),
		int(dateParts[0]),
		dateParts[2],
		hour,
		int(timeParts[1]),
		int(timeParts[2])
	];
	var parsed = "%02d.%02d.%s %02d:%02d:%02d" % paramsInOrder
	
	print(parsed)

Tipp: You can use an online GDScript Interpreter for such simple stuff, so you don't have to always launch the application and play for 20s to test :)
e.g. This one

@ChLah
Copy link
Collaborator

ChLah commented Feb 10, 2020

Caution: In #29, I alread prepared the entry point for your logic.. So please pay attention when merging

@ChLah
Copy link
Collaborator

ChLah commented Feb 11, 2020

Closed by #25

@ChLah ChLah closed this as completed Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants