Time
labridge.common.utils.time
¶
labridge.common.utils.time.datetime_to_str(date_time)
¶
Transform datetime into formatted strings.
| PARAMETER | DESCRIPTION |
|---|---|
date_time |
The datetime.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tuple[str, str]
|
Tuple[str, str]: The formatted date string and time string. |
Source code in labridge/common/utils/time.py
30 31 32 33 34 35 36 37 38 39 40 41 42 | |
labridge.common.utils.time.get_time()
¶
Get current date time in DATE_FORMAT and TIME_FORMAT
| RETURNS | DESCRIPTION |
|---|---|
Tuple[str, str]
|
Tuple[str, str]: The formatted date string and time string. |
Source code in labridge/common/utils/time.py
18 19 20 21 22 23 24 25 26 27 | |
labridge.common.utils.time.parse_date_list(start_date_str, end_date_str)
¶
Return the formatted strings of all dates from start_date to end_date.
| PARAMETER | DESCRIPTION |
|---|---|
start_date_str |
The formatted string of the start date.
TYPE:
|
end_date_str |
The formatted string of the end date.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
List[str]: The formatted date string. |
| RAISES | DESCRIPTION |
|---|---|
-ValueError
|
If the end_date is earlier than the start_date. |
Source code in labridge/common/utils/time.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
labridge.common.utils.time.parse_delta_time(time_unit)
¶
Get the delta time from a unit of a formatted time_delta string.
| PARAMETER | DESCRIPTION |
|---|---|
time_unit |
A unit of a formatted time_delta string.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
TYPE:
|
Source code in labridge/common/utils/time.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
labridge.common.utils.time.str_to_date(date_str)
¶
Transform a formatted date string to datetime.date.
| PARAMETER | DESCRIPTION |
|---|---|
date_str |
The date string in format
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
date
|
datetime.date: The date. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the date_str does not match the DATE_FORMAT`. |
Source code in labridge/common/utils/time.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
labridge.common.utils.time.str_to_datetime(date_str, time_str)
¶
Transform formatted time strings to datetime.datetime.
| PARAMETER | DESCRIPTION |
|---|---|
date_str |
The date string in format
TYPE:
|
time_str |
The time string in format
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
datetime
|
datetime.datetime: The datetime |
Source code in labridge/common/utils/time.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
labridge.common.utils.time.str_to_delta_time(time_str)
¶
Transform a formatted time_delta string to datetime.timedelta.
| PARAMETER | DESCRIPTION |
|---|---|
time_str |
The time_delta str in format
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
timedelta
|
datetime.timedelta: The time delta. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the time_str does not match the |
Source code in labridge/common/utils/time.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
labridge.common.utils.time.str_to_time(time_str)
¶
Transform a formatted time string to datetime.time.
| PARAMETER | DESCRIPTION |
|---|---|
time_str |
The time string in format
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
time
|
datetime.time: The time. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the time_str does not match the TIME_FORMAT`. |
Source code in labridge/common/utils/time.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |