-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
adding date() and datetime() short hand macros #112
adding date() and datetime() short hand macros #112
Conversation
Hi @gregology - sorry for the late reply! This sounds like a really good idea, thanks! Any way we can add this to one of the integration tests so we can make sure these macros are covered? |
d4078b5
to
87b1adf
Compare
Cheers @clausherther! Is this testing pattern suitable? |
@gregology pushed a couple of changes to get tests to pass. The return value of the macro has to be a string, also there is no |
Good call on the I have refactored the macros to output Is this test coverage and pattern suitable? |
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, thanks!
@gregology sorry, one last thing please: could we add these to the bottom of the README, maybe after Fiscal Calendar (and add them to the top index)? Even though they're utility macros, we're expecting folks to use them directly. Particularly, the fact that they don't return strings will trip up people and I'm sure we'll get questions/PRs to convert them. So, a README entry could head that off. Thanks! |
Good point @clausherther, I have updated the README to document the macros and included reasoning for outputting a |
I'll cut a release later today. Thanks! |
Problem
It takes a lot of Jinja boilerplate to generate simple datetime objects.
Compiles as
1997-09-29 06:14:00+00:00
Solution
The PR introduces
datetime()
anddate()
macros to reduce boilerplate and increase code readability.Compiles as
1997-09-29 06:14:00+00:00
This halves the character count to produce a
datetime
object.The
datetime()
macro defaults to timezone from thedbt_date:time_zone
project variable.The
date()
macro doesn't reduce the Jinja boilerplate as much but it is useful for consistency.Compiles as
1997-09-29