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

Converters from LocalDate and LocalDateTime to NSDate #322

Open
dkhalanskyjb opened this issue Nov 30, 2023 · 0 comments
Open

Converters from LocalDate and LocalDateTime to NSDate #322

dkhalanskyjb opened this issue Nov 30, 2023 · 0 comments
Labels
cookbook Useful snippets

Comments

@dkhalanskyjb
Copy link
Contributor

We received a few requests to add converters from LocalDate and LocalDateTime to NSDate. Given that NSDate is essentially the same as Instant, they could look something like this:

fun LocalDate.toNSDateAtStartOfDayIn(timeZone: TimeZone) =
  atStartOfDayIn(timeZone).toNSDate()

fun LocalDateTime.toNSDate(timeZone: TimeZone) =
  toInstant(timeZone).toNSDate()

They seem quite short, but if they are tricky to get right, maybe we could introduce them to the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cookbook Useful snippets
Projects
None yet
Development

No branches or pull requests

1 participant