diff options
author | Paul Ganssle <paul@ganssle.io> | 2017-10-25 11:57:57 -0400 |
---|---|---|
committer | Paul Ganssle <paul@ganssle.io> | 2017-10-25 11:57:57 -0400 |
commit | 45ebe06b6f35885b8615ae7d43fcb76a7ca35e99 (patch) | |
tree | be9380a5fcba2d0eff7ac9722c91f7c9ca5cea6a /dateutil/utils.py | |
parent | b0167c179235d99a58dd0ec27fc4c7ff213b4f7f (diff) | |
download | dateutil-45ebe06b6f35885b8615ae7d43fcb76a7ca35e99.tar.gz |
Improve documentation for utils.default_tzinfo
Diffstat (limited to 'dateutil/utils.py')
-rw-r--r-- | dateutil/utils.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dateutil/utils.py b/dateutil/utils.py index ae700b9..29f8181 100644 --- a/dateutil/utils.py +++ b/dateutil/utils.py @@ -24,6 +24,21 @@ def default_tzinfo(dt, tzinfo): """ Sets the the ``tzinfo`` parameter on naive datetimes only + This is useful for example when you are provided a datetime that may have + either an implicit or explicit time zone, such as when parsing a time zone + string. + + .. doctest:: + + >>> from dateutil.tz import tzoffset + >>> from dateutil.parser import parse + >>> from dateutil.utils import default_tzinfo + >>> dflt_tz = tzoffset("EST", -18000) + >>> print(default_tzinfo(parse('2014-01-01 12:30 UTC'), dflt_tz)) + 2014-01-01 12:30:00+00:00 + >>> print(default_tzinfo(parse('2014-01-01 12:30'), dflt_tz)) + 2014-01-01 12:30:00-05:00 + :param dt: The datetime on which to replace the time zone |