addproject

This commit is contained in:
qiaoxinjiu
2026-01-22 19:10:37 +08:00
commit 6994b185a3
184 changed files with 21039 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
import datetime, time
import random
class UbrdNowTime:
@staticmethod
def kw_ubrd_get_now_time():
now_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
return now_time
def get_few_days_before_or_after_current_time(self, n=0):
"""
| 功能说明: | 获取当前时间的前几天或后几天的日期 |
| 输入参数: | n | 前n天或后n天,通过正负数来区分 |
| 输入参数: | hms | 1表示返回时分秒为当前时间0表示00:00:00 |
| 返回参数: | newtime_str | 当前时间的前几天或后几天的具体日期|
| 作者信息: | 刘睿权 | 修改时间 20211025|
举例说明:
| get_few_days_before_or_after_current_time | -7 |表示当前时间往后推7天的日期|
"""
nowtime = datetime.datetime.now()
Newnowtime = nowtime - datetime.timedelta(days=n)
return datetime.datetime.strftime(Newnowtime, '%Y-%m-%d %H:%M:%S')
@staticmethod
def kw_change_format_time(r_date):
get_time = r_date / 1000
time_array = time.localtime(get_time)
other_style_time = time.strftime("%Y-%m-%d %H:%M:%S", time_array)
return other_style_time
@staticmethod
def kw_ubrd_get_random_time():
'''
获取一个随机的时间
:param r_date:
:return:
'''
get_random_week = random.randint(0, 11)
get_minite_time = get_random_week * 5
if get_minite_time == 0:
get_time = "00"
elif get_minite_time == 5:
get_time = "05"
else:
get_time = str(get_minite_time)
return get_time
@staticmethod
def kw_ubrd_get_week_day(type):
now = datetime.datetime.now()
# 计算当前周的周一和下周一的日期
current_weekday = now.weekday() # 获取当前日期的星期几星期一为0星期日为6
current_monday = now - datetime.timedelta(days=current_weekday) # 当前周的周一
next_monday = current_monday + datetime.timedelta(days=7) # 下周一
# 设置时间为0点
if type == "1":
current_day = current_monday.replace(hour=0, minute=0, second=0, microsecond=0)
else:
current_day = next_monday.replace(hour=0, minute=0, second=0, microsecond=0)
return current_day
if __name__ == '__main__':
print(UbrdNowTime.kw_ubrd_get_week_day(type=2))