Template
mirror of
https://github.com/djimboy/djimbo_template_aio3.git
synced 2026-08-26 06:57:44 +00:00
-Update
This commit is contained in:
@@ -120,18 +120,34 @@ def split_messages(get_list: list, count: int) -> list[list]:
|
||||
|
||||
|
||||
# Получение даты
|
||||
def get_date() -> str:
|
||||
return datetime.now(pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y %H:%M:%S")
|
||||
def get_date(full: bool = True) -> str:
|
||||
if full: # Полная дата с временем
|
||||
return datetime.now(pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y %H:%M:%S")
|
||||
else: # Только дата без времени
|
||||
return datetime.now(pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y")
|
||||
|
||||
|
||||
# Получение юникс даты
|
||||
# Получение unix времени
|
||||
def get_unix(full: bool = False) -> int:
|
||||
if full:
|
||||
if full: # Время в наносекундах
|
||||
return time.time_ns()
|
||||
else:
|
||||
else: # Время в секундах
|
||||
return int(time.time())
|
||||
|
||||
|
||||
# Конвертация unix в дату и наоборот, дату в unix
|
||||
def convert_date(from_time):
|
||||
if str(from_time).isdigit():
|
||||
to_time = datetime.fromtimestamp(from_time, pytz.timezone(BOT_TIMEZONE)).strftime("%d.%m.%Y %H:%M:%S")
|
||||
else:
|
||||
if " " in str(from_time):
|
||||
to_time = int(datetime.strptime(from_time, "%d.%m.%Y %H:%M:%S").timestamp())
|
||||
else:
|
||||
to_time = int(datetime.strptime(from_time, "%d.%m.%Y").timestamp())
|
||||
|
||||
return to_time
|
||||
|
||||
|
||||
# Генерация пароля
|
||||
def gen_password(len_password: int = 16, type_password: str = "default") -> str: # default, number, letter, onechar
|
||||
if type_password == "default":
|
||||
|
||||
Reference in New Issue
Block a user