Skip to content
Discussion options

You must be logged in to vote

Hi @injust thanks for posting.

The cleanest way to do this would be:

ZonedDateTime.now(TZ).start_of_day().add(days=1, seconds=-1)

Note that round could be used too, but not if the time is exactly 00:00:00.000000000 (it wouldn't round "up" in that case)

ZonedDateTime.now(TZ).round("day", mode="ceil").subtract(seconds=1)

Other notes:

  • ItemizedDelta(days=2, seconds=-1) in your example wouldn't work because it can't have a mixed sign.
  • I have been considering something like a end_of(<unit>) method. Then it'd be ZonedDateTime.now(TZ).end_of("day").subtract(seconds=1)

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
3 replies
@injust
Comment options

@injust
Comment options

@injust
Comment options

Answer selected by injust
Comment options

You must be logged in to vote
4 replies
@ariebovenberg
Comment options

@injust
Comment options

@ariebovenberg
Comment options

@injust
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants