Skip to main content

Converts the UTC time, the date and time of the region.

Project description

https://img.shields.io/badge/python-2%20%7C%203-ffc30f.svg https://img.shields.io/badge/license-MIT-ffc30f.svg https://img.shields.io/badge/platform-win32/64%20%7C%20linux32/64-ffc30f.svg https://img.shields.io/badge/pypi-v1.0.1-ffc30f.svg https://travis-ci.org/LuckyDenis/tzintime.svg?branch=master

Introduction

This package is based on the library pytz. Provides an interface, converting naive and localized time to another time zone. You can choose how the new time zone will be added - it will be added directly on the date itself or displayed separately (examples will be discussed below). You can also specify a date output template. Templates need to be configured according to the datetime library’s templates table.


Installation

python -m pip install intimezone

Example & Usage

This library supports only two methods of conversion. The first is flag='convert' (flag=None) adds a timezone to the base date. The second flag='localize' adds the time zone separately.

Test dataset:

>>> from intimezone import convert
>>> ntime = 1545695999 # naive time
>>> ltime = 1545695999.5219207 # localized time

Default settings:

>>> convert(ntime) # naive time
'Mon, 24 Dec 2018 23:59:59'
>>> convert(ltime) # localized time
'Mon, 24 Dec 2018 23:59:59'

The values flag=’convert’:

>>> convert(ntime, tz='Europe/Madrid', flag='convert') # naive time
'Tue, 25 Dec 2018 00:59:59'
>>> convert(ltime, tz='Europe/Madrid', flag='convert') # localized time
'Tue, 25 Dec 2018 00:59:59'

The values flag=’localize’:

>>> convert(ntime, tz='Europe/Madrid', flag='localize') # naive time
'Mon, 24 Dec 2018 23:59:59 +0100(CET)'
>>> convert(ltime, tz='Europe/Madrid', flag='localize') # localized time
'Mon, 24 Dec 2018 23:59:59 +0100(CET)'

Custom template for date:

>>> convert(ntime, tz='Europe/Madrid', f='%D - %H:%M:%S') # naive time
'12/25/18 - 00:59:59'
>>> convert(ltime, tz='Europe/Madrid', f='%D - %H:%M:%S') # localized time
'12/25/18 - 00:59:59'

Options

  • The library provides a single interface. In order to select in which mode to get the date, the flag (None/'convert' or 'localize') option is used.

  • The parameter moment_time can take unix time in the format int or float. Represents moment-time.

  • The time zone tz is specified in the format 'Region/City', 'Etc/GMT±12'.

  • f is responsible for generating a line at the output, through this parameter you can set a template in the style of templates of the standard library datetime.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

intimezone-1.0.2-py2.py3-none-any.whl (5.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file intimezone-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: intimezone-1.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.5

File hashes

Hashes for intimezone-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9060d4efc6564e3b5e854e9ccfee7bbd57a5939b7702d4b67d32fdf9253fb271
MD5 f800074493e1037d54b4261ca71f0ac1
BLAKE2b-256 903a0700249d6552a385f6d93e99eb59baa53490ecf5223151e086b32fdc6b1d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page