Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add option to return prior dates if ambiguous#35

Open
mvgrimes wants to merge 9 commits into
olebedev:master from
mvgrimes:feat/wants-past
Open

Add option to return prior dates if ambiguous #35
mvgrimes wants to merge 9 commits into
olebedev:master from
mvgrimes:feat/wants-past

Conversation

@mvgrimes

@mvgrimes mvgrimes commented Apr 17, 2023

Copy link
Copy Markdown

In situations where the year is ambiguous (ie, 6/20 or May 12th) the package
seems to prefer to return a future date. In some situations, I think it will
default to the current year. This patch adds WantPast to the rules.Option.
When this is true it will return the prior instance of that date. It defaults
to false which preserve the current functionality.

Some examples, assuming today is July 15, 2016:

DD/MM WantPast=False WantPast=True
14/07 2017年07月14日 2016年07月14日
15/07 2016年07月15日 2016年07月15日
16/07 2016年07月16日 2015年07月16日

There are several strategies that could be used here: WantPast, WantFuture,
Closest, ... I've only implemented WantPast, but if there was interest then
maybe converting WantPast to an enum would make more sense.

mvgrimes added 9 commits April 17, 2023 10:05
If no year is specified, then nil is returned for:
- current date July 15 in test
- future months
The OFFSET based tests probably make it easier for things like
"yesterday at 10am", but for DMY or MDY it is much simpler to compare it
to a time.Time.

Copy link
Copy Markdown
Owner

Hi @mvgrimes, thank you for the contribution! I will get back to you once I have some time to review the change.

In the meantime, do you know why the github actions haven't been triggered oner the change?

Copy link
Copy Markdown
Author

I don't have much experience with github actions, but I wonder if it is the on: trigger. I've used/seen it as:

on:
 push:

Copy link
Copy Markdown
Owner

Oh, I think I found the issue, we would need to have trigger on the pull_request as well. I'll give it a try when I have time, but feel free to add it in your PR or please add an empty commit so we can see the tests passed.

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /