Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for the "today" argument for UTCDateTime #2337
What does this PR do?
It adds the possibility to pass "today" to UTCDateTime in order to obtain a UTCDateTime object initialised at the beginning of the current day. The result is similar as:
Why was it initiated? Any relevant Issues?
Ok makes sense. I like the idea @megies mentioned better than allowing yet another input to the standard constructor for two reasons:
OK, seem indeed more interesting to have the
I also created the
c = Client("IRIS") c.get_waveforms("BE", "MEM", "", "HHZ", UTCDateTime().start_of_day(), UTCDateTime().end_of_day())
but this is open for discussion!
I really don't know about the end-of-day thingy. Feels a bit like introducing floating point glitches deliberately (although we're integer based for time internally) and also feels like redundancy? I like to use start of next day as end time in such situations, feels cleaner for me. If there's really a strong need in any situation it's still possible to just slap a
Cool, looks good.
Just a thought, would it ever be useful to have a start of month, year, minute or hour? If so maybe this should be made general like so:
UTCDateTime().start_of("day") UTCDateTime().start_of("month") ...
where the main argument would support year, month, day, hour, minute, second.
If day is the most used, however, maybe this isn't needed. It's up to you since this is your PR
I do agree that end of day stuff probably isn't needed.
Agree with using a method/property on the time object rather than constructor, and with @d-chambers that a generic solution might be helpful in the future with this as a specific case. Couple notes on prior art:
Looks like you have a