Parse strings as returned from the Windows registry into the time zone name as defined in the registry. >>> from dateutil.tzwin import tzres >>> tzr = tzres() >>> print(tzr.name_from_string('@tzres.dll,-251')) 'Dateline Daylight Time' >>> pri
(self, tzname_str)
| 92 | return resource[:nchar] |
| 93 | |
| 94 | def name_from_string(self, tzname_str): |
| 95 | """ |
| 96 | Parse strings as returned from the Windows registry into the time zone |
| 97 | name as defined in the registry. |
| 98 | |
| 99 | >>> from dateutil.tzwin import tzres |
| 100 | >>> tzr = tzres() |
| 101 | >>> print(tzr.name_from_string('@tzres.dll,-251')) |
| 102 | 'Dateline Daylight Time' |
| 103 | >>> print(tzr.name_from_string('Eastern Standard Time')) |
| 104 | 'Eastern Standard Time' |
| 105 | |
| 106 | :param tzname_str: |
| 107 | A timezone name string as returned from a Windows registry key. |
| 108 | |
| 109 | :return: |
| 110 | Returns the localized timezone string from tzres.dll if the string |
| 111 | is of the form `@tzres.dll,-offset`, else returns the input string. |
| 112 | """ |
| 113 | if not tzname_str.startswith('@'): |
| 114 | return tzname_str |
| 115 | |
| 116 | name_splt = tzname_str.split(',-') |
| 117 | try: |
| 118 | offset = int(name_splt[1]) |
| 119 | except: |
| 120 | raise ValueError("Malformed timezone string.") |
| 121 | |
| 122 | return self.load_name(offset) |
| 123 | |
| 124 | |
| 125 | class tzwinbase(tzrangebase): |