From d8334b26ecb3d984a6f8b314dd9a0d9760316307 Mon Sep 17 00:00:00 2001 From: han0 Date: Thu, 23 Feb 2023 15:10:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=20dict/timestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nc_http/tools/helpers/dict.py | 9 +++++++++ nc_http/tools/helpers/timestamp.py | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 nc_http/tools/helpers/dict.py create mode 100644 nc_http/tools/helpers/timestamp.py diff --git a/nc_http/tools/helpers/dict.py b/nc_http/tools/helpers/dict.py new file mode 100644 index 0000000..37d9d6c --- /dev/null +++ b/nc_http/tools/helpers/dict.py @@ -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()} diff --git a/nc_http/tools/helpers/timestamp.py b/nc_http/tools/helpers/timestamp.py new file mode 100644 index 0000000..b136a6d --- /dev/null +++ b/nc_http/tools/helpers/timestamp.py @@ -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