Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Removing use of pytz module / implementing our own UTC.#1044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -23,8 +23,9 @@ def _callFUT(self, value): | ||
| def test_one_second_from_epoch(self): | ||
| import datetime | ||
| import pytz | ||
| WHEN = datetime.datetime(1970, 1, 1, 0, 0, 1, tzinfo=pytz.utc) | ||
| from gcloud._helpers import UTC | ||
| WHEN = datetime.datetime(1970, 1, 1, 0, 0, 1, tzinfo=UTC) | ||
| self.assertEqual(self._callFUT(WHEN), 1000) | ||
| @@ -39,11 +40,12 @@ def test_w_none(self): | ||
| def test_w_millis(self): | ||
| import datetime | ||
| import pytz | ||
| from gcloud._helpers import UTC | ||
| from gcloud.bigquery._helpers import _total_seconds | ||
| NOW = datetime.datetime(2015, 7, 29, 17, 45, 21, 123456, | ||
| tzinfo=pytz.utc) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc) | ||
| tzinfo=UTC) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=UTC) | ||
| MILLIS = _total_seconds(NOW - EPOCH) * 1000 | ||
| self.assertEqual(self._callFUT(MILLIS), NOW) | ||
| @@ -59,34 +61,42 @@ def test_w_none(self): | ||
| def test_w_utc_datetime(self): | ||
| import datetime | ||
| import pytz | ||
| from gcloud._helpers import UTC | ||
| from gcloud.bigquery._helpers import _total_seconds | ||
| NOW = datetime.datetime.utcnow().replace(tzinfo=pytz.utc) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc) | ||
| NOW = datetime.datetime.utcnow().replace(tzinfo=UTC) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=UTC) | ||
| MILLIS = int(_total_seconds(NOW - EPOCH) * 1000) | ||
| result = self._callFUT(NOW) | ||
| self.assertTrue(isinstance(result, int)) | ||
| self.assertEqual(result, MILLIS) | ||
| def test_w_non_utc_datetime(self): | ||
| import datetime | ||
| import pytz | ||
| from gcloud._helpers import UTC | ||
| from gcloud._helpers import _UTC | ||
| from gcloud.bigquery._helpers import _total_seconds | ||
| eastern = pytz.timezone('US/Eastern') | ||
| NOW = datetime.datetime(2015, 7, 28, 16, 34, 47, tzinfo=eastern) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc) | ||
| class CET(_UTC): | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| _tzname = 'CET' | ||
| _utcoffset = datetime.timedelta(hours=-1) | ||
| zone = CET() | ||
| NOW = datetime.datetime(2015, 7, 28, 16, 34, 47, tzinfo=zone) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=UTC) | ||
| MILLIS = int(_total_seconds(NOW - EPOCH) * 1000) | ||
| result = self._callFUT(NOW) | ||
| self.assertTrue(isinstance(result, int)) | ||
| self.assertEqual(result, MILLIS) | ||
| def test_w_naive_datetime(self): | ||
| import datetime | ||
| import pytz | ||
| from gcloud._helpers import UTC | ||
| from gcloud.bigquery._helpers import _total_seconds | ||
| NOW = datetime.datetime.utcnow() | ||
| UTC_NOW = NOW.replace(tzinfo=pytz.utc) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=pytz.utc) | ||
| UTC_NOW = NOW.replace(tzinfo=UTC) | ||
| EPOCH = datetime.datetime(1970, 1, 1, tzinfo=UTC) | ||
| MILLIS = int(_total_seconds(UTC_NOW - EPOCH) * 1000) | ||
| result = self._callFUT(NOW) | ||
| self.assertTrue(isinstance(result, int)) | ||
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.