pip_services3_commons.convert.DateTimeConverter module
pip_services3_commons.convert.DateTimeConverter
DateTime conversion utilities
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.convert.DateTimeConverter.
DateTimeConverter
Bases:
object
Converts arbitrary values into Date values using extended conversion __rules: - Strings: converted using ISO time format - Numbers: converted using milliseconds since unix epoch
Example: .. code-block:: python
value1 = DateTimeConverter.to_nullable_datetime(“ABC”) // Result: None value2 = DateTimeConverter.to_nullable_datetime(“2018-01-01T11:30:00.0”) // Result: Date(2018,0,1,11,30) value3 = DateTimeConverter.to_nullable_datetime(123) // Result: Date(123)
-
static
to_datetime
(value: Any) → datetime.datetime Converts args into Date or returns current date when conversion is not possible.
- Parameters
value – the args to convert.
- Returns
Date args or current date when conversion is not supported.
-
static
to_datetime_with_default
(value: Any, default_value: datetime.datetime = None) → datetime.datetime Converts args into Date or returns default when conversion is not possible.
- Parameters
value – the args to convert.
default_value – the default args.
- Returns
Date args or default when conversion is not supported.
-
static
to_nullable_datetime
(value: Any) → Optional[datetime.datetime, None] Converts args into Date or returns null when conversion is not possible.
- Parameters
value – the args to convert.
- Returns
Date args or null when conversion is not supported.
-
static
to_utc_datetime
(value: datetime.datetime)
-
static