time-in


Nametime-in JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/seanbreckenridge/time-in
SummaryCLI tool to figure out the time somewhere else
upload_time2023-08-18 04:16:48
maintainer
docs_urlNone
authorSean Breckenridge
requires_python>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # time-in

CLI tool to figure out the time somewhere else

## Installation

Requires `python3.9+`

To install with pip, run:

```
pip install time-in
```

## Usage

```
time-in tz --help
```

If no timezone is passed, this uses [fzf](https://github.com/junegunn/fzf) to let you select a timezone from a list of all timezones/common countries/capitals.

![fzf example](https://github.com/seanbreckenridge/time-in/blob/main/.github/fzf.png?raw=true)

```
Usage: time-in tz [OPTIONS] [TZ]...

Options:
  -f, --format TEXT              format for printing dates  [default: %Y-%m-%d %H:%M:%S %Z]
  -h, --hours INTEGER            print this many localized hours in timezones
  --print-local / --skip-local   print the local time as well
  -d, --date TEXT                date to print  [default: now]
  -P, --print-local-timezone     print the local timezone name as well
  -r, --round [up|down|nearest]  round the time to the nearest hour
  --print-info / --hide-info     print timezone info/difference
  -S, --sort-diffs               sort timezones by difference from the first timezone
  --help                         Show this message and exit.
```

By default, this uses the current time, and prints the time in the timezone(s) passed.

```bash
$ time-in tz US/Eastern
Here        (+0)  2023-08-16 10:51:04 PDT
US/Eastern  (+3)  2023-08-16 13:51:04 EDT
```

If you want to print the time in the future, you can pass a date:

`$ time-in tz 'US/Eastern' --date '2023-10-16 10:30'`

or, in more human language: `$ time-in tz 'US/Eastern' --date 'in 3 hours'`

Can show multiple timezones:

```bash
$ time-in tz US/Mountain US/Central US/Eastern
Here         (+0)  2023-08-16 10:51:52 PDT
US/Mountain  (+1)  2023-08-16 11:51:52 MDT
US/Central   (+2)  2023-08-16 12:51:52 CDT
US/Eastern   (+3)  2023-08-16 13:51:52 EDT
```

To label the timezones differently, you can prepend it with a label:

```bash
$ time-in tz 'East Coast: US/Eastern' 'UK: Europe/London'
Here        (+0)  2023-08-16 10:52:04 PDT
East Coast  (+3)  2023-08-16 13:52:04 EDT
UK          (+8)  2023-08-16 18:52:04 BST
```

This can also show a range of dates, if you pass `--hours`:

```bash
$ time-in tz 'East Coast: US/Eastern' 'UK: Europe/London' --hours 12 --round down
Here        (+0)  [Aug 16]  10  11  12  13  14  15  16  17  18  19  20  21
East Coast  (+3)  [Aug 16]  13  14  15  16  17  18  19  20  21  22  23  00
UK          (+8)  [Aug 16]  18  19  20  21  22  23  00  01  02  03  04  05
```

```bash
$ time-in tz -h 6 -r down --print-local-timezone US/Eastern Europe/London Asia/Calcutta Asia/Shanghai Asia/Tokyo US/Hawaii
America/Los_Angeles  (+0)     [Aug 16]  10     11     12     13     14     15
US/Eastern           (+3)     [Aug 16]  13     14     15     16     17     18
Europe/London        (+8)     [Aug 16]  18     19     20     21     22     23
Asia/Calcutta        (+12.5)  [Aug 16]  22:30  23:30  00:30  01:30  02:30  03:30
Asia/Shanghai        (+15)    [Aug 17]  01     02     03     04     05     06
Asia/Tokyo           (+16)    [Aug 17]  02     03     04     05     06     07
US/Hawaii            (-3)     [Aug 16]  07     08     09     10     11     12
```

## Example Usage

I create a wrapper `tz` script that just passes the arguments to `time-in tz`:

```bash
#!/bin/sh
exec time-in tz "$@"
```

And then have a `tz-friends` functions in my shell for my friends in different timezones:

```
tz-friends () {
	tz "$@" 'East Coast: America/New_York' 'Japan: Asia/Tokyo' 'UK: Europe/London' 'India: Asia/Calcutta'
}
```

```bash
$ tz-friends
Here        (+0)     2023-08-17 21:12:57 PDT
East Coast  (+3)     2023-08-18 00:12:57 EDT
Japan       (+16)    2023-08-18 13:12:57 JST
UK          (+8)     2023-08-18 05:12:57 BST
India       (+12.5)  2023-08-18 09:42:57 IST
$ tz-friends -h 6 -r down
Here        (+0)     [Aug 17]  21     22     23     00     01     02
East Coast  (+3)     [Aug 18]  00     01     02     03     04     05
Japan       (+16)    [Aug 18]  13     14     15     16     17     18
UK          (+8)     [Aug 18]  05     06     07     08     09     10
India       (+12.5)  [Aug 18]  09:30  10:30  11:30  12:30  13:30  14:30
```

### Tests

```bash
git clone 'https://github.com/seanbreckenridge/time-in'
cd ./time_in
pip install '.[testing]'
flake8 ./time_in
mypy ./time_in
```

### Attributions

- The hours format was heavily influenced by [this script](https://superuser.com/a/1397116)
- Thanks to [this gist](https://gist.github.com/mjrulesamrat/0c1f7de951d3c508fb3a20b4b0b33a98) for country/city data for timezones

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/seanbreckenridge/time-in",
    "name": "time-in",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "",
    "author": "Sean Breckenridge",
    "author_email": "seanbrecke@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/89/12/1b088fcad89cc25e231db3483178b3488fde426c33e6c78638e2230108f7/time_in-0.1.1.tar.gz",
    "platform": null,
    "description": "# time-in\n\nCLI tool to figure out the time somewhere else\n\n## Installation\n\nRequires `python3.9+`\n\nTo install with pip, run:\n\n```\npip install time-in\n```\n\n## Usage\n\n```\ntime-in tz --help\n```\n\nIf no timezone is passed, this uses [fzf](https://github.com/junegunn/fzf) to let you select a timezone from a list of all timezones/common countries/capitals.\n\n![fzf example](https://github.com/seanbreckenridge/time-in/blob/main/.github/fzf.png?raw=true)\n\n```\nUsage: time-in tz [OPTIONS] [TZ]...\n\nOptions:\n  -f, --format TEXT              format for printing dates  [default: %Y-%m-%d %H:%M:%S %Z]\n  -h, --hours INTEGER            print this many localized hours in timezones\n  --print-local / --skip-local   print the local time as well\n  -d, --date TEXT                date to print  [default: now]\n  -P, --print-local-timezone     print the local timezone name as well\n  -r, --round [up|down|nearest]  round the time to the nearest hour\n  --print-info / --hide-info     print timezone info/difference\n  -S, --sort-diffs               sort timezones by difference from the first timezone\n  --help                         Show this message and exit.\n```\n\nBy default, this uses the current time, and prints the time in the timezone(s) passed.\n\n```bash\n$ time-in tz US/Eastern\nHere        (+0)  2023-08-16 10:51:04 PDT\nUS/Eastern  (+3)  2023-08-16 13:51:04 EDT\n```\n\nIf you want to print the time in the future, you can pass a date:\n\n`$ time-in tz 'US/Eastern' --date '2023-10-16 10:30'`\n\nor, in more human language: `$ time-in tz 'US/Eastern' --date 'in 3 hours'`\n\nCan show multiple timezones:\n\n```bash\n$ time-in tz US/Mountain US/Central US/Eastern\nHere         (+0)  2023-08-16 10:51:52 PDT\nUS/Mountain  (+1)  2023-08-16 11:51:52 MDT\nUS/Central   (+2)  2023-08-16 12:51:52 CDT\nUS/Eastern   (+3)  2023-08-16 13:51:52 EDT\n```\n\nTo label the timezones differently, you can prepend it with a label:\n\n```bash\n$ time-in tz 'East Coast: US/Eastern' 'UK: Europe/London'\nHere        (+0)  2023-08-16 10:52:04 PDT\nEast Coast  (+3)  2023-08-16 13:52:04 EDT\nUK          (+8)  2023-08-16 18:52:04 BST\n```\n\nThis can also show a range of dates, if you pass `--hours`:\n\n```bash\n$ time-in tz 'East Coast: US/Eastern' 'UK: Europe/London' --hours 12 --round down\nHere        (+0)  [Aug 16]  10  11  12  13  14  15  16  17  18  19  20  21\nEast Coast  (+3)  [Aug 16]  13  14  15  16  17  18  19  20  21  22  23  00\nUK          (+8)  [Aug 16]  18  19  20  21  22  23  00  01  02  03  04  05\n```\n\n```bash\n$ time-in tz -h 6 -r down --print-local-timezone US/Eastern Europe/London Asia/Calcutta Asia/Shanghai Asia/Tokyo US/Hawaii\nAmerica/Los_Angeles  (+0)     [Aug 16]  10     11     12     13     14     15\nUS/Eastern           (+3)     [Aug 16]  13     14     15     16     17     18\nEurope/London        (+8)     [Aug 16]  18     19     20     21     22     23\nAsia/Calcutta        (+12.5)  [Aug 16]  22:30  23:30  00:30  01:30  02:30  03:30\nAsia/Shanghai        (+15)    [Aug 17]  01     02     03     04     05     06\nAsia/Tokyo           (+16)    [Aug 17]  02     03     04     05     06     07\nUS/Hawaii            (-3)     [Aug 16]  07     08     09     10     11     12\n```\n\n## Example Usage\n\nI create a wrapper `tz` script that just passes the arguments to `time-in tz`:\n\n```bash\n#!/bin/sh\nexec time-in tz \"$@\"\n```\n\nAnd then have a `tz-friends` functions in my shell for my friends in different timezones:\n\n```\ntz-friends () {\n\ttz \"$@\" 'East Coast: America/New_York' 'Japan: Asia/Tokyo' 'UK: Europe/London' 'India: Asia/Calcutta'\n}\n```\n\n```bash\n$ tz-friends\nHere        (+0)     2023-08-17 21:12:57 PDT\nEast Coast  (+3)     2023-08-18 00:12:57 EDT\nJapan       (+16)    2023-08-18 13:12:57 JST\nUK          (+8)     2023-08-18 05:12:57 BST\nIndia       (+12.5)  2023-08-18 09:42:57 IST\n$ tz-friends -h 6 -r down\nHere        (+0)     [Aug 17]  21     22     23     00     01     02\nEast Coast  (+3)     [Aug 18]  00     01     02     03     04     05\nJapan       (+16)    [Aug 18]  13     14     15     16     17     18\nUK          (+8)     [Aug 18]  05     06     07     08     09     10\nIndia       (+12.5)  [Aug 18]  09:30  10:30  11:30  12:30  13:30  14:30\n```\n\n### Tests\n\n```bash\ngit clone 'https://github.com/seanbreckenridge/time-in'\ncd ./time_in\npip install '.[testing]'\nflake8 ./time_in\nmypy ./time_in\n```\n\n### Attributions\n\n- The hours format was heavily influenced by [this script](https://superuser.com/a/1397116)\n- Thanks to [this gist](https://gist.github.com/mjrulesamrat/0c1f7de951d3c508fb3a20b4b0b33a98) for country/city data for timezones\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CLI tool to figure out the time somewhere else",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/seanbreckenridge/time-in"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06d018e3c9009d766531e7bbac84fbdd44e4e461601ac79ecb7d1906bd8e55e8",
                "md5": "374cc4c8d21cd6e83df3247652394bca",
                "sha256": "fff9f5592da1740aea21b097f5c91233c5bfbf73fc4d1fd8f7d1702cf0855386"
            },
            "downloads": -1,
            "filename": "time_in-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "374cc4c8d21cd6e83df3247652394bca",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 13502,
            "upload_time": "2023-08-18T04:16:46",
            "upload_time_iso_8601": "2023-08-18T04:16:46.577739Z",
            "url": "https://files.pythonhosted.org/packages/06/d0/18e3c9009d766531e7bbac84fbdd44e4e461601ac79ecb7d1906bd8e55e8/time_in-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "89121b088fcad89cc25e231db3483178b3488fde426c33e6c78638e2230108f7",
                "md5": "5b92ac9adb925d9a3e48f2a59ba9413d",
                "sha256": "986685c9a8b3d3687660d13e9833607831c7c178daa6617ab764a296f59679fe"
            },
            "downloads": -1,
            "filename": "time_in-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "5b92ac9adb925d9a3e48f2a59ba9413d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 15076,
            "upload_time": "2023-08-18T04:16:48",
            "upload_time_iso_8601": "2023-08-18T04:16:48.403628Z",
            "url": "https://files.pythonhosted.org/packages/89/12/1b088fcad89cc25e231db3483178b3488fde426c33e6c78638e2230108f7/time_in-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-18 04:16:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "seanbreckenridge",
    "github_project": "time-in",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "time-in"
}
        
Elapsed time: 0.34351s