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

Using dateutil.parser prevents some helpful date offsets #42

Closed
adamlincoln opened this issue Apr 30, 2020 · 0 comments · Fixed by #114
Closed

Using dateutil.parser prevents some helpful date offsets #42

adamlincoln opened this issue Apr 30, 2020 · 0 comments · Fixed by #114

Comments

@adamlincoln
Copy link

While generating a date field with the date_between function block, I can use a min/max offset value of days, like the documentation says:

SomeFieldName:
  date_between:
    min: -120d
    max: -90d

but I can't use month as the unit for this offset, even though faker's date_time provider supports it. If I try:

SomeFieldName:
  date_between:
    min: -4M
    max: -3M

Then I silently get the wrong result: for min, a datetime with today's date, and 00:04:00 as the time; for max, a datetime with today's date, and 00:03:00 as the time.

It looks like this is because snowfakery sends the value through dateutil.parser.parse() first (in template_funcs:parse_date()). For a days-back value like -120d, dateutil.parser.ParserError is raised so -120d gets passed to faker and everything works. For a months-back value like -3M, dateutil.parser doesn't raise ParserError and returns an unexpected datetime.

Expected behavior: snowfakery's date values support all of faker's formats. Note that snowfakery's documentation says values like -4m are supported for months, but this has the same output as described for -4M above, and if faker's formats were followed, -4m would be four minutes ago.

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

Successfully merging a pull request may close this issue.

1 participant