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

[INVALID] Behaviour when typing a day name on its own is ambiguous #19

Closed
GoogleCodeExporter opened this issue Apr 4, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Specifying "next [some day]" or "last [some day]" behaves as expected, but
specifying "[some day]" on it's own gives you the *nearest* [some day], so
the behaviour will vary depending on the day of the week.  (Typing "monday"
today gives me "last monday", but typing "monday" on Friday will give me
"next monday".)

What is the expected output? What do you see instead?
Personally, I'd expect it to always default to "next [some day]", but that
relies on local convention -- for other people "nearest [some day]" or"last
[some day]" may be the expected behaviour.  (I trust you realise that a
*huge* subset of this problem area requires strong AI? :)

What version of the product are you using? On what operating system?
Firefox 2, OS X 10.5.1

Original issue reported on code.google.com by elbig...@gmail.com on 28 Nov 2007 at 8:45

@GoogleCodeExporter
Copy link
Author

Actually I think the problem is rather simple and works as follows.

"next monday" returns the next Monday from today.
"last monday" returns the previous Monday from today.

"monday" returns the Monday of the current week. 

Examples

// if today is monday
Date.parse('monday'); // returns today

// if today is tuesday
Date.parse('monday'); // returns yesterday

// if today is friday
Date.parse('monday'); // returns the last monday (4 days ago)

The tricky bit happen with "Sundays" because the first-day-of-the-week varies by
Culture/Language/Country. Usually the week either starts on Sunday or Monday.

Example

// if today is Friday, and the firstDayOfWeek (for the culture) is Sunday
Date.parse('sunday'); // returns "last sunday"

// if today is Friday, and the firstDayOfWeek (for the culture) is Monday
Date.parse('sunday'); // returns "next sunday"


The parser handles this all correctly. The parser knows the firstDayOfWeek from 
the
CultureInfo file. Date.CultureInfo.firstDayOfWeek.

You can also perform the same functionality in code with the API. 

Example

// if today is Friday, and the firstDayOfWeek (for the culture) is Sunday
Date.sunday(); // returns "last sunday"

// if today is Friday, and the firstDayOfWeek (for the culture) is Monday
Date.sunday(); // returns "next sunday"

Hope this helps.

Original comment by geoff%co...@gtempaccount.com on 28 Nov 2007 at 11:17

  • Changed state: Invalid

@GoogleCodeExporter
Copy link
Author

Original comment by geoff%co...@gtempaccount.com on 27 Mar 2008 at 10:21

  • Changed title: [INVALID] Behaviour when typing a day name on its own is ambiguous

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant