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

extracting_datetime() returns incorrect values if a week day is included with the utterance #187

Open
krisgesling opened this issue Apr 6, 2021 · 6 comments
Labels
bug Something isn't working en relates to english language

Comments

@krisgesling
Copy link
Contributor

Describe the bug
extracting_datetime() returns incorrect values if a week day is included with the utterance.

To Reproduce

extract_datetime("monday april 5th")

returns

[datetime.datetime(2022, 4, 11, 0, 0, tzinfo=tzfile('/usr/share/zoneinfo/Australia/Darwin')), '']

Removing "monday" from the utterance returns the correct value.

@krisgesling krisgesling added bug Something isn't working en relates to english language labels Apr 6, 2021
@ChanceNCounter
Copy link
Contributor

May be addressed by WIP #96 (I haven't checked)

@emphasize
Copy link
Contributor

emphasize commented May 1, 2021

not to say that 04/11/2022 isn't a monday.
edit: shoot, looked at may (yet the code wouldn't care if day mismatches datum)

this one year offset also occurs at _de, yet not the day offset (in your example +6) - but i guess you parsed the day before today

these are the codelines where the +6 should originate from:

elif word in days and not fromFlag:
            d = days.index(word)
            dayOffset = (d + 1) - int(today) #where today = anchorDate.strftime("%w")
            used = 1
            if dayOffset < 0:
                dayOffset += 7

@emphasize
Copy link
Contributor

emphasize commented May 1, 2021

Ok, got it. (one year offset) Since

temp = datetime.strptime(datestr, "%B %d")
extractedDate = extractedDate.replace(hour=0, minute=0, second=0)

eg (if called on the same day)

>>>2021-05-01 00:00:00+02:00 (temp)
>>>2021-05-01 00:00:00+02:00 (extractedDate)

if it has no year the case would be if extractedDate <= temp: (instead of if extractedDate < temp:)
otherwise extractedDate = extractedDate.replace(year=int(currentYear) + 1,...

skimmed through the WIP refactor and it seems it is not resolved with #96

@emphasize
Copy link
Contributor

emphasize commented May 1, 2021

dayOffset:
The problem is that weekdays in on itself are treated as relative words (what is reflected in dayOffset from now) -or in other words durations. And those durations collide with the specific date given
If you are parsing "monday may 3rd" you're asking "2 days from now after may 3rd"

Furthermore things like "Friday after May 3rd" are also not correctly parsed since the relative date (or anchorDate) should be may 3rd in that case, not datenow

@ChanceNCounter
Copy link
Contributor

I have now identified that the refactor heavily addresses weekdays. Still haven't tested as I don't know the state of it; maintainers have obviously been stretched thin lately.

Just in case, @JarbasAl ⬆️ and keep 'em coming! Edge cases galore on the way to rewrite glory, after all.

@emphasize
Copy link
Contributor

emphasize commented May 1, 2021

@ChanceNCounter Hell yeah! There's a lot to identify. And tackles (from what i can tell) those pitfalls i measly outlined. Don't sleep on that one.

And you've said there's nothing to localize :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working en relates to english language
Projects
None yet
Development

No branches or pull requests

3 participants