Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get system time/date inside of a yew app?

Tags:

rust

yew

Normally in a rust app, I'd get system time with std::time::SystemTime::now(), but that doesn't seem to work in a yew app. Instead the component I'm trying to read the system time from just silently (from the server logs) fails and in the web console I get panicked at 'time not implemented on this platform'.

Which makes sense, the client app can't just grab system time from the OS willy-nilly for security reasons. But does yew provide a way to get this from the browser?

like image 315
Richard Johnstone Avatar asked Nov 06 '22 02:11

Richard Johnstone


1 Answers

https://crates.io/crates/instant looks like it might do the job. But while it defines fn like now() I don't think that it will make crates that rely on std::time to work :-(

like image 166
Squirrel Avatar answered Dec 11 '22 08:12

Squirrel