{ "info": { "author": "Maxime Petazzoni", "author_email": "maxime.petazzoni@bulix.org", "bugtrack_url": null, "classifiers": [ "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "Timestamp library and utility\n=============================\n\n``tslib`` is a timestamp processing toolkit and library, written in\nPython. It is very helpful when dealing with the millisecond-precision\ntimestamps that we encounter all the time in computer systems, and to\nwork with human-readable time deltas away from \"now\".\n\nInstallation\n------------\n\nYou can install ``tslib`` directly from PyPI with the following command:\n\n::\n\n $ pip install tslib\n\nIf you're installing from a clone of this repository, use:\n\n::\n\n $ git clone https://github.com/mpetazzoni/tslib\n $ cd tslib/\n $ pip install -e .\n\n``tslib`` depends on ``pytz`` and ``six``, which will be installed\nautomatically.\n\nYou're now ready to use ``ts``, which should be directly available in\nyour ``$PATH``.\n\nUsage\n-----\n\n::\n\n $ ts -h\n usage: ts [-h] [-t TZ] [-n] [-i]\n\n Human readable timestamps\n\n optional arguments:\n -h, --help show this help message and exit\n -t TZ, --timezone TZ Use TZ as the local timezone\n -n, --timestamp-only Only output the resulting millisecond timestamp(s)\n -i, --inline Apply timestamp replacements inline of the incoming\n text\n\n``ts`` transforms milliseconds timestamps and human-readable deltas into\nfully qualified date and time printouts, containing:\n\n- the UTC timestamp (since Epoch)\n- the UTC time represented by the timestamp\n- the local time represented by the timestamp\n- the human-readable delta of this timestamp against current time\n\nThe output is tab-delimited and can easily be re-segmented by piping\ninto ``column -t -s \"\\t\"``.\n\nArguments can be passed as command-line arguments, or piped into ``ts``\nvia STDIN. If no input comes from either of these sources, ``ts`` will\nsimply output the current time:\n\n::\n\n $ ts\n 1423599084206 2015-02-10 20:11:24.206 UTC+0000 2015-02-10 12:11:24.206 PST-0800 0\n\nInline mode\n-----------\n\n``ts`` can operate in inline-replacement mode, for timestamps only. In\nthis mode, you can pipe in any text and ``ts`` will output it back to\nyou with all timestamps replaced with a human-readable date and time and\nhuman-readable delta representation.\n\nGiven the inherent difficulty of accurately matching timestamps, the\nmatching is limited to 13-digits millisecond precision timestamps (that\nmay be immediately followed by a ``L``). Numbers smaller, or larger than\n13 digits are not matched, and are left alone; meaning no 13-digit\nsection of them is matched and replaced.\n\n::\n\n $ echo B_b-3PAAYAA B_cJXlvAYAA B_cJXl6AcAA \\\n | xargs sfc mb g -p TSVH -f sf_checkpointTimestampMs -f sf_updatedOnMs \\\n | ts -i \\\n | column -t -s \" \"\n sf_id sf_checkpointTimestampMs sf_updatedOnMs\n B_b-3PAAYAA 2015-03-06 13:38:58.851 PST-0800 (-2w5h18m6s210) 2015-03-06 13:38:58.852 PST-0800 (-2w5h18m6s209)\n B_cJXlvAYAA 2015-03-08 09:04:36.218 PDT-0700 (-1w5d10h52m28s843) 2015-03-08 09:04:36.218 PDT-0700 (-1w5d10h52m28s844)\n B_cJXl6AcAA 2015-03-08 09:04:34.252 PDT-0700 (-1w5d10h52m30s810) 2015-03-08 09:04:34.342 PDT-0700 (-1w5d10h52m30s720)\n\nMore examples\n-------------\n\nPiping:\n\n::\n\n $ cat << EOF | ts\n pipe heredoc> 1404424797009L\n pipe heredoc> 1415917836779L\n pipe heredoc> EOF\n 1404424797009 2014-07-03 21:59:57.009 UTC+0000 2014-07-03 14:59:57.009 PDT-0700 -31w5d1h14m26s38\n 1415917836779 2014-11-13 22:30:36.779 UTC+0000 2014-11-13 14:30:36.779 PST-0800 -12w5d43m46s268\n\nUsing the column output (assuming the same input in a ``/tmp/ts.txt``\nfile):\n\n::\n\n $ cat /tmp/ts.txt | ts | cut -f4\n -31w5d1h16m17s703\n -12w5d45m37s933\n\nSorting on a column (here, by descending timestamps in first column):\n\n::\n\n $ cat /tmp/ts.txt | ts | sort -k1 -t $'\\t' -r\n 1415917836779 2014-11-13 22:30:36.779 UTC+0000 2014-11-13 14:30:36.779 PST-0800 -12w5d46m6s924\n 1404424797009 2014-07-03 21:59:57.009 UTC+0000 2014-07-03 14:59:57.009 PDT-0700 -31w5d1h16m46s694\n\nDeltas\n------\n\nHuman-readable deltas can be expressed in weeks (``w``), days (``d``),\nhours (``h``), minutes (``m``), and seconds (``s``). The remainder,\nwithout a unit, is assumed to be milliseconds. Any \"segment\" can be\nomitted, the only requirement is that the segments that are specified\nare written in descending order of span (days before hours, hours before\nminutes, etc.).\n\nHere's an example: ``-12w4d6m57s257``. Note that *hours* are missing,\nwhich simply means 12 weeks, 4 days, 6 minutes, 57 seconds and 257\nmilliseconds.\n\nAs you might have guessed, deltas can be both negative and positive. For\npositive deltas, the leading ``+`` may be omitted if units are used,\notherwise the number is assumed to be an absolute timestamp:\n\n::\n\n $ ts -1\n 1423599850752 2015-02-10 20:24:10.752 UTC+0000 2015-02-10 12:24:10.752 PST-0800 -1\n $ ts 0 1\n 0 1970-01-01 00:00:00.000 UTC+0000 1969-12-31 16:00:00.000 PST-0800 -2353w5d20h24m14s145\n 1 1970-01-01 00:00:00.001 UTC+0000 1969-12-31 16:00:00.001 PST-0800 -2353w5d20h24m14s144\n $ ts +1\n 1423599855941 2015-02-10 20:24:15.941 UTC+0000 2015-02-10 12:24:15.941 PST-0800 1\n\nUsing a different local timezone\n--------------------------------\n\nThe third column shows the timestamp's representation in local time. It\ndefaults to the ``US/Pacific`` timezone but this can be overridden with\nthe ``-t`` command-line argument, passing in a timezone name that\n``pytz`` understands:\n\n::\n\n $ ts -t Europe/Paris\n 1423600015955 2015-02-10 20:26:55.955 UTC+0000 2015-02-10 21:26:55.955 CET+0100 0\n\nAbsolute, human-readable offsets from Epoch\n-------------------------------------------\n\nBy prefixing a human-readable delta with an equal sign (``=``), you\nobtain an absolute offset from the Epoch. The side-effect of this is\nthat it allows for converting a human-readable delta into its\ncorresponding millisecond duration.\n\n::\n\n $ ts -n '=1h'\n 3600000\n $ ts '=1d'\n 86400000 1970-01-02 00:00:00.000 UTC+0000 1970-01-01 16:00:00.000 PST-0800 -2365w6d21h56m20s98\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mpetazzoni/tslib", "keywords": "", "license": "Apache Software License v2", "maintainer": "", "maintainer_email": "", "name": "tslib", "package_url": "https://pypi.org/project/tslib/", "platform": "", "project_url": "https://pypi.org/project/tslib/", "project_urls": { "Homepage": "https://github.com/mpetazzoni/tslib" }, "release_url": "https://pypi.org/project/tslib/1.6/", "requires_dist": null, "requires_python": "", "summary": "A library for dealing with human-readable time offsets and timestamps", "version": "1.6" }, "last_serial": 3885034, "releases": { "1.1": [ { "comment_text": "", "digests": { "md5": "71853f4bb440b98abaa92d4c658a8036", "sha256": "e45ed9ab1430fa42a9657f592b480bc24dd1b1519ba006edb01dfd3425ac3081" }, "downloads": -1, "filename": "tslib-1.1-py2-none-any.whl", "has_sig": false, "md5_digest": "71853f4bb440b98abaa92d4c658a8036", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9661, "upload_time": "2016-03-19T00:36:17", "url": "https://files.pythonhosted.org/packages/b2/be/1f3b747d2e0331c7131df8751525860d77d4e515f9c1c9d26833db98e2d0/tslib-1.1-py2-none-any.whl" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "d90688341065639c820b9bb0ab772b21", "sha256": "c78e6620a11dd7e17dbf6ca2f3c932f031b18fddd32caca4515d3f1ad964c4a1" }, "downloads": -1, "filename": "tslib-1.2-py2-none-any.whl", "has_sig": false, "md5_digest": "d90688341065639c820b9bb0ab772b21", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9697, "upload_time": "2016-03-23T22:50:27", "url": "https://files.pythonhosted.org/packages/bf/a2/91410899d607e80573bfb5e8ead2a0c307ddeb8e5abe6afe2c0e14cea30b/tslib-1.2-py2-none-any.whl" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "512d56d69e186eed51a2993b8a4da23f", "sha256": "0ac8b10b49a20922dfe9dfc08256fa7faa6659dccb8e80326f6ed2662d10821a" }, "downloads": -1, "filename": "tslib-1.3-py2-none-any.whl", "has_sig": false, "md5_digest": "512d56d69e186eed51a2993b8a4da23f", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9737, "upload_time": "2016-03-23T23:41:55", "url": "https://files.pythonhosted.org/packages/a9/f9/e315af5394c2ad2ad557b3f887f2242253a498cc096764f49118054163e3/tslib-1.3-py2-none-any.whl" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "9c6cf804794c9cbf3cba402f16b30704", "sha256": "a43a1c63484d7f18b732d36c02265eeee90cf7841c98434c9e6db51b0e708aab" }, "downloads": -1, "filename": "tslib-1.4-py2-none-any.whl", "has_sig": false, "md5_digest": "9c6cf804794c9cbf3cba402f16b30704", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 9779, "upload_time": "2016-03-24T20:23:38", "url": "https://files.pythonhosted.org/packages/e0/90/c7f9114270c2b0249c080ce1fcac4ac84aacb0c9bfb372fa254cce68120e/tslib-1.4-py2-none-any.whl" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "a324b3e0e44aed3b855bcb2d52d4f06e", "sha256": "f275895066ce2528da5070ecf570f416ad0a223f246a334f09093fecb09221cd" }, "downloads": -1, "filename": "tslib-1.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "a324b3e0e44aed3b855bcb2d52d4f06e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10053, "upload_time": "2016-09-23T22:50:54", "url": "https://files.pythonhosted.org/packages/a6/8d/5c16d8cf7e42059a21b2a19a6803fc6f3f347f5633c35b46290f2abf8d26/tslib-1.5-py2.py3-none-any.whl" } ], "1.5.1": [ { "comment_text": "", "digests": { "md5": "3e796ef8b40de13a3f95f7ac8a7b4f7c", "sha256": "a49a1bd5586ca3472d7bcdc4f16000c8fa558e4ead20128e5017ea9c04791f89" }, "downloads": -1, "filename": "tslib-1.5.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3e796ef8b40de13a3f95f7ac8a7b4f7c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10094, "upload_time": "2016-09-23T22:53:54", "url": "https://files.pythonhosted.org/packages/01/c6/477c70f205dbd8cd8ccc45f3e6b729574e75e0eb28dfe88569284ebbc04e/tslib-1.5.1-py2.py3-none-any.whl" } ], "1.6": [ { "comment_text": "", "digests": { "md5": "6355b18128b4f63fb19978ab36048e31", "sha256": "95f864456cd337275b330bbb0a15a0ad15733535924cf73b683622efeab61a8a" }, "downloads": -1, "filename": "tslib-1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6355b18128b4f63fb19978ab36048e31", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6872, "upload_time": "2018-05-21T21:18:48", "url": "https://files.pythonhosted.org/packages/c6/19/8e6cfd61b15fa2dbf0090d459260864b6d42be771e9eb1489e57c3baa268/tslib-1.6-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6355b18128b4f63fb19978ab36048e31", "sha256": "95f864456cd337275b330bbb0a15a0ad15733535924cf73b683622efeab61a8a" }, "downloads": -1, "filename": "tslib-1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "6355b18128b4f63fb19978ab36048e31", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6872, "upload_time": "2018-05-21T21:18:48", "url": "https://files.pythonhosted.org/packages/c6/19/8e6cfd61b15fa2dbf0090d459260864b6d42be771e9eb1489e57c3baa268/tslib-1.6-py2.py3-none-any.whl" } ] }