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

RFC: date-time builtin type #5122

Open
WilstonOreo opened this issue Apr 23, 2024 · 2 comments
Open

RFC: date-time builtin type #5122

WilstonOreo opened this issue Apr 23, 2024 · 2 comments
Labels
rfc Request for comments: proposals for changes

Comments

@WilstonOreo
Copy link
Contributor

WilstonOreo commented Apr 23, 2024

When you build Calendars and other Date/Time-Widgets, properties with a date-time builtin type might be useful.
Here are a few suggestions how a builtin type date-time could look like:

component Calendar {
in property <date-time> date-time;
}

date-time should behave similar to a JavaScript Date object with convenience functions:

  • hours() -> int, minutes() -> int, month_name() -> string
  • to_string(format: string) -> string: date-time.to_string("DD/MM/YYYY"), date-time.to_string("hh:mm:ss")
  • to_locale_string(locale: string) -> string:

Additionally, there could also be a DateTime namespace to hold functions to construct date-time instances:

  • DateTime.now()
  • DateTime.new(year: int, month: int, day: int, hours: int, minutes: int, seconds: int)

Comments/Suggestions welcome!

@tronical tronical added the rfc Request for comments: proposals for changes label Apr 23, 2024
@tronical
Copy link
Member

Implementation wise I think that perhaps this needs to be feature conditional and we could wrap icu_calendar’s Date<AnyCalendar>. We’d also wrap that in C++ maybe, or is there something else we should use instead?

@WilstonOreo
Copy link
Contributor Author

Yes it should be a feature because there might not even be a system clock on certain MCUs :) Wrapping icu_calendar Date<AnyCalendar> and exposing it as an FFI should be fine. Although it might be good to use std::time in C++ to save a few CPU cycles?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc Request for comments: proposals for changes
Projects
None yet
Development

No branches or pull requests

2 participants