Coder Social home page Coder Social logo

tzview's Introduction

tzview

PyPI Build Status License: MIT

View datetime in different time zones.

Given a time zone and datetime, tzview can find the datetime at other time zones.

The time zone names are those as specified in the Olsen time zone database (tz).

tzview merely leverages pytz package to get the job done.

Installation

You need Python>=3.6 to use tzview.

It can be installed from PyPI with pip using

pip install tzview

Usage

Defaults

The string 'local' can be used to specify the local time zone. This is the source time zone by default.

The string 'now' can be used to specify the local datetime. This is the source datetime by default.

In addition to the time zone names, tzview can also identify the time zone of a limited number of cities (Eg: Hanoi -> Asia/Ho_Chi_Minh).

Command line usage

To get the current time at Tokyo relative to your computer's current time and time zone, use

python3 -m tzview Asia/Tokyo

to get something like

09:47 PM, 06-Jul-2020 (+0900): Asia/Tokyo

You could provide source datetime using --dt option and source time zone with --from-tz option. Like

python3 -m tzview --dt "2020-03-23 11:32:34" --from-tz Asia/Tokyo Europe/Oslo Africa/Bamako

to get an output like

03:32 AM, 23-Mar-2020 (+0100): Europe/Oslo
02:32 AM, 23-Mar-2020 (+0000): Africa/Bamako

The input and output datetime formats can be changed with options.

Use python3 -m tzview --help for more.

Usage as module

The tzview() function can be used. It accepts the extension name as string.

Return value would be a list of timezone aware datetimes.

For example,

>>> from tzview import tzview
>>> tzview(['Europe/Oslo'])  # Based on current time
[datetime.datetime(2020, 5, 24, 12, 6, 14, 272335, tzinfo=<DstTzInfo 'Europe/Oslo' CEST+2:00:00 DST>)]


>>> tzview(['Europe/Athens', 'Asia/Singapore'], dt_str="2020-May-24 13:11:07", dt_format="%Y-%b-%d %H:%M:%S")
[datetime.datetime(2020, 5, 24, 10, 41, 7, tzinfo=<DstTzInfo 'Europe/Athens' EEST+3:00:00 DST>), datetime.datetime(2020, 5, 24, 15, 41, 7, tzinfo=<DstTzInfo 'Asia/Singapore' +08+8:00:00 STD>)]

Why

It is useful to figure out the time when you got to attend meetings coordinated from a different time zone.

Or when calling a friend at another timezone to know the time of the day there.

That's what I use it for. :-)

tzview's People

Contributors

ju-sh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.