feat: 新增 dict/timestamp
This commit is contained in:
9
nc_http/tools/helpers/dict.py
Normal file
9
nc_http/tools/helpers/dict.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
from nc_http.tools.helpers import uncamelize, camelize
|
||||||
|
|
||||||
|
|
||||||
|
def uncamelize_dict(d):
|
||||||
|
return {uncamelize(k): v for k, v in d.items()}
|
||||||
|
|
||||||
|
|
||||||
|
def camelize_dict(d):
|
||||||
|
return {camelize(k): v for k, v in d.items()}
|
21
nc_http/tools/helpers/timestamp.py
Normal file
21
nc_http/tools/helpers/timestamp.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
def get_day_list(start_time, end_time, day_limits=365):
|
||||||
|
"""
|
||||||
|
:param start_time:
|
||||||
|
:param end_time:
|
||||||
|
:param day_limits:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
mod = start_time % (24 * 60 * 60)
|
||||||
|
if mod > 0:
|
||||||
|
day = start_time - mod + (24 * 60 * 60)
|
||||||
|
else:
|
||||||
|
day = start_time
|
||||||
|
day_list = []
|
||||||
|
for _ in range(day_limits):
|
||||||
|
if day <= end_time:
|
||||||
|
day_list.append(day)
|
||||||
|
day += (24 * 60 * 60)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
|
return day_list
|
Reference in New Issue
Block a user