-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43d322c
commit 8085266
Showing
4 changed files
with
48 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
cx-freeze | ||
pytz | ||
tzlocal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'''A setup script to demonstrate build using pytz | ||
This version requires the zoneinfo in the file system | ||
''' | ||
# | ||
# Run the build process by running the command 'python setup.py build' | ||
# | ||
# If everything works well you should find a subdirectory in the build | ||
# subdirectory that contains the files needed to run the script without Python | ||
|
||
import distutils | ||
import sys | ||
import os | ||
|
||
from cx_Freeze import setup, Executable | ||
|
||
dir_name = "exe.%s-%s.2" % \ | ||
(distutils.util.get_platform(), sys.version[0:3]) | ||
build_exe = os.path.join('build', dir_name) | ||
|
||
setup(name='test_pytz', | ||
version='0.2', | ||
description='cx_Freeze script to test pytz', | ||
executables=[Executable("test_pytz.py")], | ||
options={ | ||
'build_exe': {'zip_include_packages': ["*"], | ||
'zip_exclude_packages': ["pytz"], | ||
'build_exe': build_exe} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
'''sample to show the datetime in RFC1123 (timezone is required)''' | ||
from datetime import datetime | ||
import datetime | ||
import pytz | ||
import tzlocal | ||
|
||
RFC1123 = '%a, %d %b %Y %H:%M:%S %z' | ||
|
||
try: | ||
tz = tzlocal.get_localzone() | ||
print('Using your local timezone:', tz.zone) | ||
except pytz.exceptions.UnknownTimeZoneError as exc: | ||
print('Detected your local timezone:', exc.args[0]) | ||
print("WARNING: fail to load pytz timezones, fallback to UTC") | ||
tz = pytz.utc | ||
finally: | ||
print(datetime.now(tz).strftime(RFC1123)) | ||
utc_time = datetime.datetime.utcnow() | ||
print('UTC time:', utc_time.strftime(RFC1123)) | ||
|
||
tz1 = pytz.timezone('America/Sao_Paulo') | ||
brz_time = tz1.fromutc(utc_time) | ||
print('Brazil time:', brz_time.strftime(RFC1123)) | ||
|
||
tz2 = pytz.timezone('US/Eastern') | ||
eas_time = tz2.fromutc(utc_time) | ||
print('US Eastern time:', eas_time.strftime(RFC1123)) |