time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.06k stars 261 forks source link

feat: added `Date::today()` method. #664

Closed avhz closed 4 months ago

avhz commented 4 months ago

Hi, thanks for the great library.

Just wondering if there could be a method added to get a Date with today's date.

OffsetDateTime has .now_utc() for example, which means I can do something like:

let today: Date = OffsetDateTime::now_utc().date();

But I thought it might be convenient for Date to have its own now method. e.g.

let today: Date = Date::today();

Happy to adjust the PR if needed of course.

jhpratt commented 4 months ago

This is a deliberate omission that was present in v0.2 but removed in v0.3. Assuming a time zone is not an acceptable tradeoff.

avhz commented 4 months ago

No worries.

Could you clarify what you mean? I must be missing something. Where does the time zone data come into play if it returns a Date?

jhpratt commented 4 months ago

It isn't the same day everywhere on earth.

avhz commented 4 months ago

Ah I see what you mean. Cheers!