Skip to content

Faster way to get number of days between two Dates? #255

Answered by BurntSushi
bluetech asked this question in Q&A
Discussion options

You must be logged in to vote

OK thanks, that helps a lot.

What do you actually do with the Date values? Would it make sense if Jiff provided a civil::UnixEpochDays? It would effectively provide the same civil::Date API, but use a "number of days since the Unix epoch" representation. That would make these "number of days" calculations quite a bit faster. It wouldn't match your epoch of course, but if you just stay in the UnixEpochDays representation, that will just be a little arithmetic.

But yeah, most of the time being spent here is converting between YYYY-MM-DD and Unix epoch days.

Replies: 1 comment 14 replies

Comment options

You must be logged in to vote
14 replies
@bluetech
Comment options

@BurntSushi
Comment options

@bluetech
Comment options

@BurntSushi
Comment options

Answer selected by bluetech
@bluetech
Comment options

@BurntSushi
Comment options

@BurntSushi
Comment options

@bluetech
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