simple datetime
A library that we can get datetime simply and easily
Installation
Install using pip:
pip install sdate
Install using source code:
git clone https://github.com/qiueer/sdate cd sdate python setup.py install
Usage
Get datetime information currently:
>>> from sdate import sdate
>>> sdate()
{ 'date': '2016-03-14',
'time': '11:42:21',
'datetime': '2016-03-14 11:42:21',
'datetimestr': '20160314114221284',
'day': 14,
'hour': 11,
'iso8601': '2016-03-14T11:42:21',
'iso8601_ms': '2016-03-14T11:42:21.284319+08:00',
'iso8601_ms_tz': '2016-03-14T11:42:21.284319+08:00',
'iso8601_tz': '2016-03-14T11:42:21+08:00',
'microsecond': 284319,
'minute': 42,
'month': 3,
'second': 21,
'tzname': 'GMT+8',
'unix_timestamp': 1457926941,
'weekday': 0,
'year': 2016}
Get datetime information, before four hours:
>>> from sdate import sdate
>>> sdate(hours=-4)
{ 'date': '2016-03-14',
'time': '07:51:12',
'datetime': '2016-03-14 07:51:12',
'datetimestr': '20160314075112200',
'day': 14,
'hour': 7,
'iso8601': '2016-03-14T07:51:12',
'iso8601_ms': '2016-03-14T07:51:12.200265+08:00',
'iso8601_ms_tz': '2016-03-14T07:51:12.200265+08:00',
'iso8601_tz': '2016-03-14T07:51:12+08:00',
'microsecond': 200265,
'minute': 51,
'month': 3,
'second': 12,
'tzname': 'GMT+8',
'unix_timestamp': 1457913072,
'weekday': 0,
'year': 2016}
Convert unix timestamp to sdate, that we can use it to get more information:
>>> from sdate import sdate
>>>sd=sdate().from_unix_timestamp(1457895842)
>>>print sd
{ 'date': '2016-03-14',
'time': '03:04:02',
'datetime': '2016-03-14 03:04:02',
'datetimestr': '201603140304020',
'day': 14,
'hour': 3,
'iso8601': '2016-03-14T03:04:02',
'iso8601_ms': '2016-03-14T03:04:02+08:00',
'iso8601_ms_tz': '2016-03-14T03:04:02+08:00',
'iso8601_tz': '2016-03-14T03:04:02+08:00',
'microsecond': 0,
'minute': 4,
'month': 3,
'second': 2,
'tzname': 'GMT+8',
'unix_timestamp': 1457895842,
'weekday': 0,
'year': 2016}
>>> sd.datetime_str()
'201603140304020'
Reset sdate, the arguments are same as Constructor:
>>>sd=sdate().from_unix_timestamp(1457895842)
>>>print sd
{ 'date': '2016-03-14',
'time': '03:04:02',
'datetime': '2016-03-14 03:04:02',
'datetimestr': '201603140304020',
'day': 14,
'hour': 3,
'iso8601': '2016-03-14T03:04:02',
'iso8601_ms': '2016-03-14T03:04:02+08:00',
'iso8601_ms_tz': '2016-03-14T03:04:02+08:00',
'iso8601_tz': '2016-03-14T03:04:02+08:00',
'microsecond': 0,
'minute': 4,
'month': 3,
'second': 2,
'tzname': 'GMT+8',
'unix_timestamp': 1457895842,
'weekday': 0,
'year': 2016}
>>> sd.reset()
{ 'date': '2016-03-14',
'time': '13:05:13',
'datetime': '2016-03-14 13:05:13',
'datetimestr': '20160314130513729',
'day': 14,
'hour': 13,
'iso8601': '2016-03-14T13:05:13',
'iso8601_ms': '2016-03-14T13:05:13.729126+08:00',
'iso8601_ms_tz': '2016-03-14T13:05:13.729126+08:00',
'iso8601_tz': '2016-03-14T13:05:13+08:00',
'microsecond': 729126,
'minute': 5,
'month': 3,
'second': 13,
'tzname': 'GMT+8',
'unix_timestamp': 1457931913,
'weekday': 0,
'year': 2016}
Methods that we can use:
>>>sd.weekofday() 0 >>>sd.hour() 13 >>>sd.month() 3 >>>sd.datetime_str() '20160314130513729' >>>sd.iso8601_ms_tz() '2016-03-14T13:05:13.729126+08:00' >>>sd.datetime() '2016-03-14 13:05:13' >>>sd.iso8601_ms() '2016-03-14T13:05:13.729126+08:00' >>>sd.second() 13 >>>sd.iso8601_tz() 2016-03-14T13:05:13+08:00 >>>sd.minute() 5 >>>sd.year() 2016 >>>sd.date() '2016-03-14' >>>sd.unix_timestamp() 1457931913 >>>sd.iso8601() '2016-03-14T13:05:13' >>>sd.day() 14 >>>sd.microsecond() 729126 >>>sd.tzname() 'GMT+8' >>>sd.time() '13:05:13'
Support + Contributing
Feel free to make pull requests, or report issues via the repo:
Metadata
Release files for sdate 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sdate-0.1.2.tar.gz | 3.8 kB | Without provenance | Details for sdate-0.1.2.tar.gz |
Release files / sdate-0.1.2.tar.gz
| Download URL | sdate-0.1.2.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
337fa24160253e08610fabba686c4b5f86dafc1fefd470feee770e7274492cd8
|
|
BLAKE2b-256 checksum How to use checksums |
ab3def573e40a64f0e21979b3cee759844833591b62e8d2629f50f233fc4d3e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sdate 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.