`timez` --- Time package supporting chain call
==================================================
timez is a time package supporting chain call.
install and use:
::
pip install timez
Example
-------
::
from timez import timez
# get datetime str of previous day with specified hours
>>> timez(f'{timez.now().delta(days=-1).date_str()} 10:00:00').datetime_str()
'2021-04-04 10:00:00'
# get unix timestamp of previous day
>>> timez.now().delta(days=-1).uts(is_ms=True)
1627211818635
# get corresponding unix timestamp with specified datetime str
>>> timez('2021-04-04 18:23:12').uts()
1617531792
# get datetime str of UTC time which is converted and down sampled by local time
>>> timez.now().delta(hours=8).ds(minutes=5).datetime_str()
'2021-04-04 08:05:00'
Initialize
----------
There are 5 ways to initialize an timez object.
::
# 1. init with time str, format '%Y{}%m{}%d', '%Y{}%m{}%d %H{}%M{}%S' date_sep could be '','-','/', time_sep could be '',':'.
>>> timez('20210404')
>>> timez('2021-04-04 18:23:12')
>>> timez('2021/04/04 18:23:12')
# 2. init with unix timestamp, support second and milliseconds, default as second
>>> timez(1617531792)
>>> timez(1617531792000, is_ms=True) # if is milliseconds, is_ms=True
>>> timez(1617531792.123) # float is also supported
# 3. init with custom datetime str, use timez.strp(time: str, fmt: str)
>>> timez.strp('2021-04-04 18:23', fmt='%Y-%m-%d %H:%M')
# 4. init datetime.datetime object
>>> dt = datetime.datetime.now()
>>> timez(dt)
# 5. init with timetuple
>>> timez((2021, 4, 4, 18, 23, 12))
>>> timez(['2021', '04', '04', '18', '23', '12'])
class timez
---------------
* timez.now() -> timez
get current local time.
* timez.today() -> timez
get current date, hour minute second is 00:00:00.
* timez.strp(time: str, fmt: str) -> timez
init timez from custom time str format.
* timez.uts(is_ms=False) -> int
get unix timestamp, if is_ms=True, get milliseconds.
* timez.date_str(date_sep='-') -> str
get date str, sep include '', '-', '/'.
* time_str(time_sep=':') -> str
get time str, 'time_sep' is sep include '', ':'.
* datetime_str(date_sep='-', time_sep=':') -> str
get datetime str, date_sep and time_sep same to above.
* join(datetime_str: str, fmt: str) -> timez
join timez self with given time str.
Notice: There is no date or time range checking, be careful
::
>>> timez('2021-04-04 18:23:12').join('23:59:59').__str__()
'2021-04-04 23:59:59'
>>> timez('2021-04-04 23:59:59').join('10 235959', fmt='%d %H%M%S').__str__()
'2021-04-10 23:59:59'
>>> timez('2021-04-04 18:23:12').join('10', fmt='%d').__str__()
'2021-04-10 18:23:12'
* strf(fmt) -> str
get custom time str with given fmt.
* pop() -> datetime.datetime
get datetime.datetime object from timez instance
* delta(days=0, seconds=0, minutes=0, hours=0) -> timez
get offset time.
* ds(hours=None, minutes=None, seconds=None) -> timez
down sample time, example as follows.
::
>>> timez('2021-04-04 18:23:12').ds(hours=5).__str__()
'2021-04-04 15:23:12'
>>> timez('2021-04-04 18:23:12').ds(minutes=5).__str__()
'2021-04-04 18:20:12'
>>> timez('2021-04-04 18:23:12').ds(seconds=5).__str__()
'2021-04-04 18:23:10'
>>> timez('2021-04-04 18:23:12').ds(minutes=5, seconds=0).__str__()
'2021-04-04 18:20:00'
>>> timez('2021-04-04 18:23:12').ds(hours=0, minutes=0, seconds=0).__str__()
'2021-04-04 00:00:00'
>>> timez('2021-04-04 18:23:12').ds(hours=17, minutes=5, seconds=5).__str__()
'2021-04-04 17:20:10'
Raw data
{
"_id": null,
"home_page": "https://github.com/AvinsWang/timez",
"name": "timez",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "timez,py-itime,python time",
"author": "Avins Wang",
"author_email": "avinswang@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/fb/77/9e453adee3f73448b250498ec16c8a163c27584e7d54bf5c64747c795df3/timez-0.0.1.tar.gz",
"platform": null,
"description": "`timez` --- Time package supporting chain call\n==================================================\n\ntimez is a time package supporting chain call.\n\ninstall and use:\n\n::\n\n pip install timez\n\n\nExample\n-------\n\n::\n\n from timez import timez\n\n # get datetime str of previous day with specified hours\n >>> timez(f'{timez.now().delta(days=-1).date_str()} 10:00:00').datetime_str()\n '2021-04-04 10:00:00'\n\n # get unix timestamp of previous day\n >>> timez.now().delta(days=-1).uts(is_ms=True)\n 1627211818635\n\n # get corresponding unix timestamp with specified datetime str\n >>> timez('2021-04-04 18:23:12').uts()\n 1617531792\n\n # get datetime str of UTC time which is converted and down sampled by local time\n >>> timez.now().delta(hours=8).ds(minutes=5).datetime_str()\n '2021-04-04 08:05:00'\n\nInitialize\n----------\nThere are 5 ways to initialize an timez object.\n::\n\n # 1. init with time str, format '%Y{}%m{}%d', '%Y{}%m{}%d %H{}%M{}%S' date_sep could be '','-','/', time_sep could be '',':'.\n >>> timez('20210404')\n >>> timez('2021-04-04 18:23:12')\n >>> timez('2021/04/04 18:23:12')\n\n # 2. init with unix timestamp, support second and milliseconds, default as second\n >>> timez(1617531792)\n >>> timez(1617531792000, is_ms=True) # if is milliseconds, is_ms=True\n >>> timez(1617531792.123) # float is also supported\n\n # 3. init with custom datetime str, use timez.strp(time: str, fmt: str)\n >>> timez.strp('2021-04-04 18:23', fmt='%Y-%m-%d %H:%M')\n\n # 4. init datetime.datetime object\n >>> dt = datetime.datetime.now()\n >>> timez(dt)\n\n # 5. init with timetuple\n >>> timez((2021, 4, 4, 18, 23, 12))\n >>> timez(['2021', '04', '04', '18', '23', '12'])\n\n\nclass timez\n---------------\n\n\n* timez.now() -> timez\n get current local time.\n* timez.today() -> timez\n get current date, hour minute second is 00:00:00.\n* timez.strp(time: str, fmt: str) -> timez\n init timez from custom time str format.\n* timez.uts(is_ms=False) -> int\n get unix timestamp, if is_ms=True, get milliseconds.\n* timez.date_str(date_sep='-') -> str\n get date str, sep include '', '-', '/'.\n* time_str(time_sep=':') -> str\n get time str, 'time_sep' is sep include '', ':'.\n* datetime_str(date_sep='-', time_sep=':') -> str\n get datetime str, date_sep and time_sep same to above.\n* join(datetime_str: str, fmt: str) -> timez\n join timez self with given time str.\n Notice: There is no date or time range checking, be careful\n\n::\n >>> timez('2021-04-04 18:23:12').join('23:59:59').__str__()\n '2021-04-04 23:59:59'\n >>> timez('2021-04-04 23:59:59').join('10 235959', fmt='%d %H%M%S').__str__()\n '2021-04-10 23:59:59'\n >>> timez('2021-04-04 18:23:12').join('10', fmt='%d').__str__()\n '2021-04-10 18:23:12'\n\n\n* strf(fmt) -> str\n get custom time str with given fmt.\n* pop() -> datetime.datetime\n get datetime.datetime object from timez instance\n* delta(days=0, seconds=0, minutes=0, hours=0) -> timez\n get offset time.\n* ds(hours=None, minutes=None, seconds=None) -> timez\n down sample time, example as follows.\n\n::\n >>> timez('2021-04-04 18:23:12').ds(hours=5).__str__()\n '2021-04-04 15:23:12'\n >>> timez('2021-04-04 18:23:12').ds(minutes=5).__str__()\n '2021-04-04 18:20:12'\n >>> timez('2021-04-04 18:23:12').ds(seconds=5).__str__()\n '2021-04-04 18:23:10'\n >>> timez('2021-04-04 18:23:12').ds(minutes=5, seconds=0).__str__()\n '2021-04-04 18:20:00'\n >>> timez('2021-04-04 18:23:12').ds(hours=0, minutes=0, seconds=0).__str__()\n '2021-04-04 00:00:00'\n >>> timez('2021-04-04 18:23:12').ds(hours=17, minutes=5, seconds=5).__str__()\n '2021-04-04 17:20:10'\n",
"bugtrack_url": null,
"license": "LGPL-3.0",
"summary": "Easy time class supporting chain called, deprecated name: py-itime",
"version": "0.0.1",
"project_urls": {
"Download": "http://pypi.python.org/pypi/timez",
"Homepage": "https://github.com/AvinsWang/timez"
},
"split_keywords": [
"timez",
"py-itime",
"python time"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3a81772453b891f1e392d6dfa6083aaf412d7c72a70ecdcf3d9440ee521d4499",
"md5": "5388f1d1cfcb1e46c688a1facf045597",
"sha256": "e7e8b92f42dd59979777f3cab7559be242c12979b6fb872f3279b2cc5a738059"
},
"downloads": -1,
"filename": "timez-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5388f1d1cfcb1e46c688a1facf045597",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17224,
"upload_time": "2023-07-13T08:13:56",
"upload_time_iso_8601": "2023-07-13T08:13:56.820079Z",
"url": "https://files.pythonhosted.org/packages/3a/81/772453b891f1e392d6dfa6083aaf412d7c72a70ecdcf3d9440ee521d4499/timez-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fb779e453adee3f73448b250498ec16c8a163c27584e7d54bf5c64747c795df3",
"md5": "a0aa3fc70839f7ccbf27f9d43f9028d4",
"sha256": "3058ad6b5d27d98a440ddec605da75a5b7ca59a93759203c4add76cfc37a7faa"
},
"downloads": -1,
"filename": "timez-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "a0aa3fc70839f7ccbf27f9d43f9028d4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16894,
"upload_time": "2023-07-13T08:13:59",
"upload_time_iso_8601": "2023-07-13T08:13:59.704846Z",
"url": "https://files.pythonhosted.org/packages/fb/77/9e453adee3f73448b250498ec16c8a163c27584e7d54bf5c64747c795df3/timez-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-13 08:13:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AvinsWang",
"github_project": "timez",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "timez"
}