converter¶
-
class
convert2.converter.
Anything2Int
[source]¶ Parse anything to
int
The logic:
- for int:
- for float:
- for str: extract int
- for datetime: it’s utc timestamp
- for date: it’s days from ordinary
- for timedelta: its total seconds
-
class
convert2.converter.
Anything2Float
[source]¶ Parse anything to float
The logic:
- for int:
- for float:
- for str:
- for datetime: it’s utc timestamp
- for date: it’s days from ordinary
- for timedelta: its total seconds
-
class
convert2.converter.
Anything2Str
[source]¶ Parse anything to
str
The logic:
- bytes: auto detect encoding and then decode
- other: stringlize it
-
class
convert2.converter.
Anything2Datetime
[source]¶ Parse anything to
datetime.datetime
.The logic:
- for int, it’s the
datetime.from_utctimestamp(value)
- for float, it’s the
datetime.from_utctimestamp(value)
- for str, try to parse
datetime
- for datetime type, it’s itself
- for date type, it’s the time at 00:00:00
- for int, it’s the