Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving just a day name without "last" or "next" or "this" silently returns today #1

Open
rrthomas opened this issue Apr 23, 2013 · 2 comments

Comments

@rrthomas
Copy link

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.

@stuartskelton
Copy link

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'.

@rrthomas
Copy link
Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants