# `Date` class
A simplified date and time class for time manipulation. This library is intended for personal and business applications where assuming every solar day has 24 * 60 * 60 seconds is considered accurate. [See *GMT vs UTC* below](//#GMT%20vs%20UTC).
## Assumptions
* **All time is in GMT** - Timezone math is left to be resolved at the human endpoints: Machines should only be dealing with one type of time; without holes, without overlap, and with minimal context.
* **Single time type** - There is no distinction between dates, datetime and times; all measurements in the time dimension are handled by one type called `Date`. This is important for treating time as a vector space.
* **Standard range comparision** - All time range comparisons have been standardized to `min <= value < max`. The minimum is inclusive (`<=`), and the maximum is exclusive (`<`).
# `Date` properties
### `Date()` constructor
The `Date()` method will convert unix timestamps, millisecond timestamps, various string formats and simple time formulas to create a GMT time
### `now()` staticmethod ###
Return `Date` instance with millisecond resolution (in GMT).
### `eod()` staticmethod ###
Return end-of-day: Smallest `Date` which is greater than all time points in today. Think of it as tomorrow. Same as `now().ceiling(DAY)`
### `today()` staticmethod ###
The beginning of today. Same as `now().floor(DAY)`
### range(min, max, interval) staticmethod ###
Return an explicit list of `Dates` starting with `min`, each `interval` more than the last, but now including `max`. Used in defining partitions in time domains.
### `floor(duration=None)` method
This method is usually used to perform date comparisons at the given resolution (aka `duration`). Round down to the nearest whole duration. `duration` as assumed to be `DAY` if not provided.
### `format(format="%Y-%m-%d %H:%M:%S")` method
Just like `strftime`
### `milli` property
Number of milliseconds since epoch
### `unix` property
Number of seconds since epoch
### `add(duration)` method
Add a `duration` to the time to get a new `Date` instance. The `self` is not modified.
### `addDay()` method
Convenience method for `self.add(DAY)`
# `Duration` class
Represents the difference between two `Dates`. There are two scales:
* **`DAY` scale** - includes seconds, minutes, hours, days and weeks.
* **`YEAR` scale** - includes months, quarters, years, and centuries.
### `Duration()` constructor
Create a new `Duration` by name, by formula, by `timespan`, or (more rarely) number of milliseconds.
### `floor(interval=None)` method
Round down to nearest `interval` size.
### `seconds` property
return total number of seconds (including partial) in this duration (estimate given for `YEAR` scale)
### `total_seconds()` method ###
Same as the `seconds` property
### `round(interval, decimal=0)` method ###
Return number of given `interval` rounded to given `decimal` places
### `format(interval, decimal=0)` method ###
Return a string representing `self` using given `interval` and `decimal` rounding
# Time Vector Space
The `Date` and `Duration` objects are the point and vectors in a one dimensional vector space. As such, the `+` and `-` operators are allowed. Comparisons with (`>`, `>=`, `<=`, `<`) are also supported.
## GMT vs UTC
The solar day is he most popular timekeeping unit. This library chose GMT (UT1) for its base clock because of its consistent seconds in a solar day. UTC suffers from inconsistent leap seconds and makes time-math difficult, even while forcing us to make pedantic conclusions like some minutes do not have 60 seconds. Lucky for us Python's implementation of UTC (`datetime.utcnow()`) is wrong, and implements GMT: Which is what we use.
## Error Analysis
Assuming we need a generous leap second each 6 months (the past decade saw only 4 leap seconds), then GMT deviates from UTC by up to 1 seconds over 181 days (December to June, 15,638,400 seconds) which is an error rate `error = 1/15,638,400 = 0.000006395%`. If we want to call the error "noise", we have a 70dB signal/noise ratio. All applications that can tolerate this level of error should use GMT as their time basis.
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共23个文件
py:14个
txt:4个
pkg-info:2个
资源分类:Python库 所属语言:Python 资源全名:mo-times-5.53.21241.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
mo-times-5.53.21241.tar.gz (23个子文件)
mo-times-5.53.21241
PKG-INFO 6KB
mo_times.egg-info
PKG-INFO 6KB
requires.txt 104B
SOURCES.txt 586B
top_level.txt 84B
dependency_links.txt 1B
LICENSE 16KB
mo_times
vendor
dateutil
tz.py 32KB
easter.py 3KB
parser.py 33KB
zoneinfo
__init__.py 3KB
tzwin.py 6KB
__init__.py 278B
rrule.py 40KB
relativedelta.py 17KB
__init__.py 0B
durations.py 12KB
dates.py 16KB
timer.py 3KB
__init__.py 511B
setup.cfg 42B
setup.py 5KB
README.md 4KB
共 23 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功