Is there a way to get current datetime?

65 views
Skip to first unread message

Evžen Wybitul

unread,
Nov 12, 2020, 11:09:29 AM11/12/20
to Pyret Discuss
Hey, 

I’m looking for a way to get current datetime (akin do Date.now() in js), specifically to enable some simple benchmarking of algorithm implementations. Is there any datetime module in Pyret, or any way to call into javascript and use it directly?

Thanks,
Evžen

Ben Lerner

unread,
Nov 12, 2020, 11:21:46 AM11/12/20
to pyret-...@googlegroups.com, Evžen Wybitul

You can use time-now() to return the value of JS’s new Date().getTime(), i.e. the current elapsed milliseconds since January 1, 1970 at 0:00:00 UTC with millisecond resolution. This function isn’t currently documented, since it’s not currently really supported (we haven’t really decided how we want to expose DateTime information yet, but we needed something for our own benchmarks…), but you can use it.

--
You received this message because you are subscribed to the Google Groups "Pyret Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyret-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyret-discuss/31f4ad08-14b1-402d-8639-a752451cfd4cn%40googlegroups.com.

Evžen Wybitul

unread,
Nov 12, 2020, 11:51:39 AM11/12/20
to Pyret Discuss

Great news ! I knew it was worth asking around.
Dne čtvrtek 12. listopadu 2020 v 17:21:46 UTC+1 uživatel Ben Lerner napsal:
Reply all
Reply to author
Forward
0 new messages