Chrono utility #16

Closed
opened 2025-01-26 22:01:13 +00:00 by ElhamAryanpur · 8 comments
ElhamAryanpur commented 2025-01-26 22:01:13 +00:00 (Migrated from github.com)

There should exist a utility for time management and calculation

There should exist a utility for time management and calculation
ElhamAryanpur commented 2025-06-16 10:47:35 +00:00 (Migrated from github.com)

This should be a pretty good set of fields to be added for the date and time:

https://www.w3schools.com/jsref/jsref_obj_date.asp

This should be a pretty good set of fields to be added for the date and time: https://www.w3schools.com/jsref/jsref_obj_date.asp
khushmmehta commented 2025-06-16 20:00:31 +00:00 (Migrated from github.com)

Are we going to be heavy on timezone-based computation? More than just conversions from local time?

Are we going to be heavy on timezone-based computation? More than just conversions from local time?
ElhamAryanpur commented 2025-06-16 20:15:06 +00:00 (Migrated from github.com)

I think just the UTC with the functionality in the listed link should be a good start. Other timezones and functionality can be derived from that base as time goes, and if theres more demand, we can implement them into Astra.

So don't worry, can keep it simple.

I think just the UTC with the functionality in the listed link should be a good start. Other timezones and functionality can be derived from that base as time goes, and if theres more demand, we can implement them into Astra. So don't worry, can keep it simple.
khushmmehta commented 2025-06-16 20:20:06 +00:00 (Migrated from github.com)

Then i agree with you, chrono is definitely a better option since it will be easier in the future when timezone functionality might evolve. Also, can you provide me with a good source so i can make some sense of what to do with the lua interop?

Then i agree with you, chrono is definitely a better option since it will be easier in the future when timezone functionality might evolve. Also, can you provide me with a good source so i can make some sense of what to do with the lua interop?
ElhamAryanpur commented 2025-06-16 20:30:28 +00:00 (Migrated from github.com)

yeah for sure, the added libraries usually come in 3 parts:

  1. actual code for the library, e.g. https://github.com/ArkForgeLabs/Astra/blob/main/src/components/crypto.rs
  2. adding Lua interop (the UserData), making a lua function and then setting it to the globals with prefix 'astra_internal__', and then running the registration code in this function: github.com/ArkForgeLabs/Astra@9dacc84316/src/components/mod.rs (L15) so that the runtime can do it whenever everything else is registered.
  3. adding lua type definitions at the https://github.com/ArkForgeLabs/Astra/blob/main/src/lua/astra.lua. After adding them, depending on type of functionality, you need a function to link to the globals you have set (and a type definition class).

After you're done with all of those, you can run 'cargo run -- astra_build.lua pack' for bundling the lua code. That should be it. Can test it out with writing an example as well!

yeah for sure, the added libraries usually come in 3 parts: 1) actual code for the library, e.g. https://github.com/ArkForgeLabs/Astra/blob/main/src/components/crypto.rs 2) adding Lua interop (the `UserData`), making a lua function and then setting it to the globals with prefix 'astra_internal__', and then running the registration code in this function: https://github.com/ArkForgeLabs/Astra/blob/9dacc84316ee330b3011bc3f6a09f05330a1aca0/src/components/mod.rs#L15 so that the runtime can do it whenever everything else is registered. 3) adding lua type definitions at the https://github.com/ArkForgeLabs/Astra/blob/main/src/lua/astra.lua. After adding them, depending on type of functionality, you need a function to link to the globals you have set (and a type definition class). After you're done with all of those, you can run 'cargo run -- astra_build.lua pack' for bundling the lua code. That should be it. Can test it out with writing an example as well!
ElhamAryanpur commented 2025-06-16 20:30:48 +00:00 (Migrated from github.com)

I should really put these on a CONTRIBUTING.md or in docs for other contributors too

I should really put these on a CONTRIBUTING.md or in docs for other contributors too
khushmmehta commented 2025-06-17 05:47:21 +00:00 (Migrated from github.com)

For the parse function, should I implement all these formats?

Edit: Would it be fine if I just let the user specify the format?

For the parse function, should I implement all these [formats](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse#examples)? Edit: Would it be fine if I just let the user specify the format?
ElhamAryanpur commented 2025-06-17 20:12:03 +00:00 (Migrated from github.com)

I think chrono can parse it itself,

Just get it as String and it should be fine

I think chrono can parse it itself, Just get it as String and it should be fine
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ArkForgeLabs/Astra#16
No description provided.