Python datetime.tzname() Examples
The following are 10 code examples for showing how to use datetime.tzname(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
datetime
, or try the search function
.
Example 1
Project: GTDWeb Author: lanbing510 File: dateformat.py License: GNU General Public License v2.0 | 6 votes |
def e(self): """ Timezone name. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tzinfo.tzname and not datetime.tzname # because datatime.tzname does not expect Unicode return self.data.tzinfo.tzname(self.data) or "" except NotImplementedError: pass return ""
Example 2
Project: python Author: Yeah-Kun File: dateformat.py License: Apache License 2.0 | 6 votes |
def e(self): """ Timezone name. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tzinfo.tzname and not datetime.tzname # because datatime.tzname does not expect Unicode return self.data.tzinfo.tzname(self.data) or "" except NotImplementedError: pass return ""
Example 3
Project: python Author: Yeah-Kun File: dateformat.py License: Apache License 2.0 | 6 votes |
def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" name = None try: name = self.timezone.tzname(self.data) except Exception: # pytz raises AmbiguousTimeError during the autumn DST change. # This happens mainly when __init__ receives a naive datetime # and sets self.timezone = get_default_timezone(). pass if name is None: name = self.format('O') return six.text_type(name)
Example 4
Project: openhgsenti Author: drexly File: dateformat.py License: Apache License 2.0 | 6 votes |
def e(self): """ Timezone name. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tzinfo.tzname and not datetime.tzname # because datatime.tzname does not expect Unicode return self.data.tzinfo.tzname(self.data) or "" except NotImplementedError: pass return ""
Example 5
Project: openhgsenti Author: drexly File: dateformat.py License: Apache License 2.0 | 6 votes |
def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" name = None try: name = self.timezone.tzname(self.data) except Exception: # pytz raises AmbiguousTimeError during the autumn DST change. # This happens mainly when __init__ receives a naive datetime # and sets self.timezone = get_default_timezone(). pass if name is None: name = self.format('O') return six.text_type(name)
Example 6
Project: python2017 Author: bpgc-cte File: dateformat.py License: MIT License | 6 votes |
def e(self): """ Timezone name. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tzinfo.tzname and not datetime.tzname # because datatime.tzname does not expect Unicode return self.data.tzinfo.tzname(self.data) or "" except NotImplementedError: pass return ""
Example 7
Project: python2017 Author: bpgc-cte File: dateformat.py License: MIT License | 6 votes |
def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" name = None try: name = self.timezone.tzname(self.data) except Exception: # pytz raises AmbiguousTimeError during the autumn DST change. # This happens mainly when __init__ receives a naive datetime # and sets self.timezone = get_default_timezone(). pass if name is None: name = self.format('O') return six.text_type(name)
Example 8
Project: GTDWeb Author: lanbing510 File: dateformat.py License: GNU General Public License v2.0 | 5 votes |
def T(self): """ Time zone of this machine; e.g. 'EST' or 'MDT'. If timezone information is not available, this method returns an empty string. """ if not self.timezone: return "" name = self.timezone.tzname(self.data) if self.timezone else None if name is None: name = self.format('O') return six.text_type(name)
Example 9
Project: luscan-devel Author: blackye File: dateformat.py License: GNU General Public License v2.0 | 5 votes |
def e(self): "Timezone name if available" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tzinfo.tzname and not datetime.tzname # because datatime.tzname does not expect Unicode return self.data.tzinfo.tzname(self.data) or "" except NotImplementedError: pass return ""
Example 10
Project: luscan-devel Author: blackye File: dateformat.py License: GNU General Public License v2.0 | 5 votes |
def T(self): "Time zone of this machine; e.g. 'EST' or 'MDT'" name = self.timezone and self.timezone.tzname(self.data) or None if name is None: name = self.format('O') return six.text_type(name)