-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add 'now' variable to Snowfakery #485
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple of small comments, but I'm going to go ahead and approve because I don't think my questions are showstoppers.
b: ${{now}} | ||
""" | ||
generate(StringIO(yaml), {}, None) | ||
assert datetime.fromisoformat(generated_rows.table_values("A", 0, "a")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems a little imprecise -- it's verifying that now
generates a date, but it doesn't verify that it sets the correct date. Would it be worth taking the time to mock out datetime.now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/index.md
Outdated
#### `now` | ||
|
||
The `now` variable returns a datetime | ||
representing the current moment. Experimentally, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to specifically mention that this returns the value of datetime.now()
? I don't don't if the target audience is savvy enough to know what that means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think not, in general. I'll see what Peter says.
7eed778
to
1d6cae0
Compare
I addressed David's suggestion that the date have a timezone in d657218. Since this PR was created, Snowfakery adopted a UTC-default policy. |
The `today` variable returns a date representing the current date. This date does not change chanage during the execution of a single recipe. | ||
The `today` variable returns a date | ||
representing the current date. This date | ||
will not chanage during the execution of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will not chanage during the execution of | |
doesn't change during the execution of |
current_datetime_without_microseconds: ${{int(now.timestamp())}} | ||
``` | ||
|
||
This would generate field values similar to these: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would generate field values similar to these: | |
The above example generates field values similar to these: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The
now
variable returns a datetime representing the current moment. It stores microsecond precision.