| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 95897f9 commit 6fd0902
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -105,6 +105,9 @@ def __init__(self, secs_west_of_utc, name=None): | |||
| 105 | 105 | self._offset = timedelta(seconds=-secs_west_of_utc) | |
| 106 | 106 | self._name = name or 'fixed' | |
| 107 | 107 | ||
| 108 | + def __reduce__(self): | ||
| 109 | + return tzoffset, (-self._offset.total_seconds(), self._name) | ||
| 110 | + | ||
| 108 | 111 | def utcoffset(self, dt): | |
| 109 | 112 | return self._offset | |
| 110 | 113 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,7 @@ | |||
| 4 | 4 | # This module is part of GitPython and is released under | |
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | ||
| 7 | + import pickle | ||
| 7 | 8 | import tempfile | |
| 8 | 9 | import time | |
| 9 | 10 | from unittest import skipIf | |
@@ -280,3 +281,9 @@ def test_from_timestamp(self): | |||
| 280 | 281 | # Wrong offset: UTC-9000, should return datetime + tzoffset(UTC) | |
| 281 | 282 | altz = utctz_to_altz('-9000') | |
| 282 | 283 | self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz)) | |
| 284 | + | ||
| 285 | + def test_pickle_tzoffset(self): | ||
| 286 | + t1 = tzoffset(555) | ||
| 287 | + t2 = pickle.loads(pickle.dumps(t1)) | ||
| 288 | + self.assertEqual(t1._offset, t2._offset) | ||
| 289 | + self.assertEqual(t1._name, t2._name) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments