You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I pass as the parse value "12:00", DateTimeX::Easy->new() returns today at noon. If I pass "last sunday 12:00", it returns noon last Sunday. If I pass "sunday 12:00" then it returns today at noon, even if today isn't Sunday. If I pass "sunda 12:00" then it returns an error.
I am using 0.089, which appears to be the latest release.
The text was updated successfully, but these errors were encountered:
I can see how that could be frustrating, would you default a non prefixed day (eg. Sunday), go to the NEXT Sunday or THIS Sunday. This sort of thing would open a nuance type bug.
I feel the correct solution would be to 'warn' if a day was passed in without a 'last/next/this'.
A non-prefixed day should by default refer to the current week (note, this could mean the future OR the past). You should therefore check the first day of the week in the locale, which is possible at least on GNU systems (see _NL_TIME_FIRST_WEEKDAY); for others a preference might be nice.
You could also allow the caller to specify a default interpretation for an unprefixed day (i.e. "future, this week, past": I'd expect a calendar app's "add appointment" function to default to "future", and a radio-listening app (a real use case I have for DateTimeX::Easy) to default to "past".
I agree it's a good idea to warn: you can use the warning message to say which day was picked, which can act as useful feedback to the user rather than an annoying "you should be using a prefix!" complaint (so it remains comfortable to use for users happy with the default interpretation).
waterkip
pushed a commit
to waterkip/datetimex-easy
that referenced
this issue
Aug 7, 2022
If I pass as the parse value "12:00", DateTimeX::Easy->new() returns today at noon. If I pass "last sunday 12:00", it returns noon last Sunday. If I pass "sunday 12:00" then it returns today at noon, even if today isn't Sunday. If I pass "sunda 12:00" then it returns an error.
I am using 0.089, which appears to be the latest release.
The text was updated successfully, but these errors were encountered: