|
backup = test_tzinfo
+ if icuTzinfo is None and backup is not None:
+ icuTzinfo = backup
+ if tzical_tzid is not None:
+ tzid_mapping[tzical_tzid] = icuTzinfo
+ # if we have an unknown timezone, we'll return floating
+ return TimeZone.floating if icuTzinfo is None else icuTzinfo
+
+def force_datetime(dt, tzinfo=None):
+ """
+ If dt is a datetime, return dt, if a date, add time(0) and return.
+
+ @param dt: The input.
+ @type dt: C{datetime} or C{date}
+
+ @return: A C{datetime}
+ """
+ if tzinfo is None:
+ tzinfo = TimeZone.floating
+ if type(dt) == datetime:
+ if dt.tzinfo is None:
+ return dt.replace(tzinfo=tzinfo)
+ else:
+ return dt
+ elif type(dt) == date:
+ return datetime.combine(dt, time(0, tzinfo=tzinfo))
</ins></span></pre>
</div>
</div>
</body>
</html>
|
|