You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the hood, it uses external dateparser library that's fully compatible with ISO 8601, and it simplifies working
9
-
with date & time stamps.
8
+
It properly handles the Daylight Saving Time (summer time), and provides functionality for creating, manipulating, and formatting timestamps in various formats
9
+
and precisions.
10
10
11
-
It also handles properly the Daylight Saving Time (summer time).
11
+
Under the hood, it uses external dateparser library that's fully compatible with ISO 8601, and it simplifies working with date & time stamps.
12
12
13
13
### Installation
14
14
@@ -57,8 +57,337 @@ ts.as_file_date == '20090213'
57
57
ts.as_file_ts =='20090213-233130'
58
58
```
59
59
60
+
## Classes
61
+
62
+
### `TS`
63
+
64
+
The TS class, a subclass of float, represents Unix timestamps in seconds. It includes additional methods for timestamp manipulation and formatting.
65
+
66
+
#### Key Methods and Properties
67
+
68
+
-`now_dt()`: Returns the current datetime in UTC.
69
+
-`now_ms()`, now_us, now_ns: Returns the current timestamp in various precisions.
70
+
-`now()`: Returns the current TS instance.
71
+
-`from_iso()`: Parses an ISO string to a TS instance.
72
+
-`timestamp()`: Returns the timestamp as a TS instance.
73
+
-`as_iso()`, `as_iso_date()`, `as_iso_date_basic()`, `as_iso_tz()`, `as_iso_basic()`: Various ISO format representations.
74
+
-`as_file_ts()` and `as_file_date()`: File-friendly timestamp formats.
75
+
-`as_sec()`, `as_ms()`, `to_sec()`: Conversions to different precisions with deprecation notices.
76
+
-`floor()` and `ceil()`: Methods for flooring and ceiling the timestamp.
77
+
-`weekday()` and `isoweekday()`: Methods to get the day of the week.
78
+
-*Arithmetic Operations*: Overloaded methods for arithmetic.
79
+
80
+
#### now_dt
81
+
82
+
-**Description**: Returns the current datetime in UTC.
The TSMsec class, a subclass of float, and it's used as a factory class to instantiate TS from milliseconds precision.
303
+
304
+
After instantiation, the TSMsec instance is identical to TS instance, and it includes all the same methods and properties.
305
+
306
+
### `iTS`
307
+
308
+
- The iTS class, a subclass of int, represents Unix timestamps in seconds. It includes additional methods for timestamp manipulation and formatting.
309
+
- It inherits from`BaseTS`and`int` classes, so it exposes all the methods `TS` has, as well as it supports all the arithmetic operations `int` supports.
310
+
- It's identical to `TS` class, but all the methods that return `TS` will return `iTS` instead, excepting the timestamp(), which returns `TS`.
311
+
312
+
#### Key Methods and Properties
313
+
314
+
- The same as`TS`class, but all the methods that return`TS` will return`iTS` instead.
315
+
316
+
### `iTSms`
317
+
318
+
- The iTSms class, a subclass of int, represents Unix timestamps in milliseconds. It includes additional methods for timestamp manipulation and formatting.
319
+
- It inherits from`BaseTS`and`int` classes, so it exposes all the methods `TS` has, as well as it supports all the arithmetic operations `int` supports.
320
+
- It's identical to `TSMsec` class, but all the methods that return `TS` will return `iTSms` instead, excepting the timestamp(), which returns `TS`.
321
+
322
+
### `iTSus`
323
+
324
+
- The iTSus class, a subclass of int, represents Unix timestamps in microseconds. It includes additional methods for timestamp manipulation and formatting.
325
+
- It inherits from`BaseTS`and`int` classes, so it exposes all the methods `TS` has, as well as it supports all the arithmetic operations `int` supports.
326
+
- It's identical to `TS` class, but all the methods that are expected to return `TS` will return `iTSus` instead, excepting the timestamp(), which returns `TS`.
327
+
328
+
### `iTSns`
329
+
330
+
- The iTSns class, a subclass of int, represents Unix timestamps in nanoseconds. It includes additional methods for timestamp manipulation and formatting.
331
+
- It inherits from`BaseTS`and`int` classes, so it exposes all the methods `TS` has, as well as it supports all the arithmetic operations `int` supports.
332
+
- It's identical to `TS` class, but all the methods that are expected to return `TS` will return `iTSns` instead, excepting the timestamp(), which returns `TS`.
333
+
-**Note**: The `iTSns`classis only available for Python >=3.8, and it support ns level now precision by using `time.time_ns()` instead of `time.time()`.
334
+
60
335
### Changelog
61
336
337
+
##### 0.1.13
338
+
- TypeHint update: `TS.as_ms()` now returns `iTSms` instead of simple `int`
339
+
- Added more documentation to README.md
340
+
341
+
##### 0.1.12
342
+
343
+
- Added dTS object
344
+
345
+
##### 0.1.11
346
+
347
+
- fixed the pickling/unpickling of TSMsec objects by instantiating the TSMsec as actually an instance of TS
0 commit comments