WebAssembly / wasi-blobstore

10 stars 10 forks source link

More explicit date-and-time resource #7

Open Mossaka opened 1 year ago

Mossaka commented 1 year ago

Currently timestamp is defined as a u64 type, which doesn't really specify what kind of date and time representation it is. It might be seconds since Unix Epoch or it might noe be. I would suggest to come up with a more explictly date and time resource which provides methods to convert timestamp to different representations. Minimally, it should contain two methods

  1. unix_timestamp() -> i64 to get the Unix timestamp
  2. unix_timestamp_nanos() -> i128 to get the Unix timestamp in nanoseconds

In addition, we might want to consider adding from functions to convert unix timestamp this sturct as constructors.

We may want to define other functions such as date and time to return date and time representations resp.

CC @devigned

ossfellow commented 1 week ago

@Mossaka, this would, more or less, duplicate what wasi-clocks/wall-clock already does; so, reusing what's already provided might be a better approach than building anew.