Is there a library or a blessed way of handling date times in lustre? I'm looking to grab a date from an <input type="date"> and store it as DateTime like object to then send to the server. I've looked at birl but it doesn't quite fit the need
#Lustre date time handling
1 messages · Page 1 of 1 (latest)
if you dont need to manipulate it i'd probably just use an external type
Oh! cool I didn't know that that was a thing. So basically this example
// A type with no Gleam constructors
pub type DateTime
// An external function that creates an instance of the type
@external(javascript, "./my_package_ffi.mjs", "now")
pub fn now() -> DateTime
// The `now` function in `./my_package_ffi.mjs` looks like this:
// export function now() {
// return new Date();
// }
pub fn main() {
io.debug(now())
}
An interactive introduction and reference to the Gleam programming language. Learn Gleam in your browser!
Thanks!
yeah!
@dire spoke What functionality did you need that birl did not provide?
Hmmmmm I forgot now sorry. It's been a week. I think it had something about getting the current time or getting time from a calendar input from the html. Is there something that I may have missed?
You can use the now function to get the current time
And I assume the calendar input is a string in which case you can use the parse function to get a value of type Time!
Ah I must have missed it. Either way this was really good learning. Thanks @feral gull
Is there a version in lustre_ui for date inputs? I'm looking through the demo and haven't found anything yet.
nawh not at the momen