#Lustre date time handling

1 messages · Page 1 of 1 (latest)

dire spoke
#

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

GitHub

datetime handling for gleam. Contribute to massivefermion/birl development by creating an account on GitHub.

crystal light
#

if you dont need to manipulate it i'd probably just use an external type

dire spoke
#

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!

crystal light
#

yeah!

feral gull
#

@dire spoke What functionality did you need that birl did not provide?

dire spoke
#

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?

feral gull
#

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!

dire spoke
#

Ah I must have missed it. Either way this was really good learning. Thanks @feral gull

dire spoke
#

Is there a version in lustre_ui for date inputs? I'm looking through the demo and haven't found anything yet.

crystal light
#

nawh not at the momen