-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding date() and datetime() short hand macros (#112)
* adding date() and datetime() short hand macros * adding test for date() and datetime() macros * Rename macro file * Add tz default handling * Update tests * outputing datetime object and casting in tests * updating README with date and datetime marco instructions --------- Co-authored-by: Claus Herther <[email protected]>
- Loading branch information
1 parent
2169d5c
commit 7a7cd80
Showing
4 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% macro date(year, month, day) %} | ||
{{ return(modules.datetime.date(year, month, day)) }} | ||
{% endmacro %} | ||
|
||
{% macro datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tz=None) %} | ||
{% set tz = tz if tz else var("dbt_date:time_zone") %} | ||
{{ return( | ||
modules.datetime.datetime( | ||
year=year, month=month, day=day, hour=hour, | ||
minute=minute, second=second, microsecond=microsecond, | ||
tzinfo=modules.pytz.timezone(tz) | ||
) | ||
) }} | ||
{% endmacro %} |