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

Does time need to be < 24h? (use case: elapsed time) #952

Closed
silverhook opened this issue Jan 13, 2023 · 5 comments
Closed

Does time need to be < 24h? (use case: elapsed time) #952

silverhook opened this issue Jan 13, 2023 · 5 comments

Comments

@silverhook
Copy link

I have a use-case where I want to log how much time something took.

In that case should I use the (local?) time type? Which may be against the (local) time type intention.

time = 342:12:29

or do I need to declare it as a string? Which is just very confusing since there is also a time type (and it is OK if you use it within the range of 24h).

time = "342:12:29"
@marzer
Copy link
Contributor

marzer commented Jan 13, 2023

Yes, the Time type in TOML is a time point, as in, a specific time of day (optionally at a specific date using the full Date-Time formats).

What you're asking for is a Duration type; there's a proposal to add one to the language here: #514

@silverhook
Copy link
Author

Ah, thanks. I searched before and at a very lazy look that issue did not seem the same, but you’re right.

I’m closing this issue in favour of #514 then.

@silverhook silverhook closed this as not planned Won't fix, can't repro, duplicate, stale Jan 13, 2023
@marzer
Copy link
Contributor

marzer commented Jan 13, 2023

If you're not too interested in down-to-the-nanosecond precision, a user-friendly workaround for this is to simply use a float, e.g.

timeout_minutes = 2.5 # 2 min 30 sec

@silverhook
Copy link
Author

@marzer That’s a good option, thanks. But my use case is at the same time kinda niche and silly, and not really that important – I use TOML to keep my highscores and a few games record also how much time something took.

I decided to just save it as a string for now.

@marzer
Copy link
Contributor

marzer commented Jan 13, 2023

Ah yup, in that case you'd definitely want precision, lest you incur the wrath of angry players :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants