Incorrect date when using .when with weekdays
See original GitHub issuehello! 👋
There appears to be an issue with maya.when()
when using weekday names.
>>> today = maya.now()
>>> print(today)
'Sun, 15 Apr 2018 16:58:03 GMT'
>>> tomorrow = maya.when("monday", prefer_past=False)
>>> print(tomorrow)
'Mon, 09 Apr 2018 00:00:00 GMT'
dateparser seems to handle this correctly, but only when the setting ‘PREFER_DATES_FROM’ is set to ‘future’.
>>> dateparser.parse("monday")
datetime.datetime(2018, 4, 9, 0, 0)
>>> dateparser.parse("monday", settings={"PREFER_DATES_FROM": "future"})
datetime.datetime(2018, 4, 16, 0, 0)
>>> dateparser.parse("Apr 16")
datetime.datetime(2018, 4, 16, 0, 0)
>>> dateparser.parse("Apr 16", settings={"PREFER_DATES_FROM": "past"})
datetime.datetime(2017, 4, 16, 0, 0)
The default setting for dateparser appears to be "current_period"
from dateparser/dateparser_data/settings.py.
As the only way to alter the ‘PREFER_DATES_FROM’ setting is change prefer_past
, there is currently no way to get the future day in this instance.
I’ll open a PR with a failing test.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
weekday function returns wrong date-what is DIRECT method ...
WEEKDAY(A1) returns the number 1 through 7, which TEXT would consider as the dates 1/1/1900 through 1/7/1900 in that context. The day of...
Read more >Weekday function in is showing incorrect days - Stack Overflow
I have used the following code from the lubridate package. + 3 has been used to start at Tuesday as the 1st Jan...
Read more >Incorrect Weekday based on Date - Tableau Community
In the Customers by Weekday view, it is recognizing each date 1 weekday later than it should be. Example: Monday, April 3rd, 2017...
Read more >On what day of the week were you born? - Plus magazine!
Recently we learnt a very impressive trick: tell us the date you were born and we will almost immediately tell you what day...
Read more >Docs - Moment.js
Week year, week, and weekday tokens. For these, the lowercase tokens use the locale aware week start days, and the uppercase tokens use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sounds even better! I’m looking forward to accept the change in the PR you’ve already made 😉
Done in #147