# Copyright (c) Huawei Technologies Co., Ltd. 2026-2026. All rights reserved.
# OpenOLC is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# `http://license.coscl.org.cn/MulanPSL2`
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
import time
from enum import Enum
class TimeUtils:
@staticmethod
def get_milliseconds():
"""
返回当前毫秒时间戳
:return:
"""
return int(time.time() * 1000)
class TimeUnit(Enum):
SECOND = 1000 # 1秒 = 1000 毫秒
MINUTE = 60 * 1000
HOUR = 60 * 60 * 1000
DAY = 24 * 60 * 60 * 1000
WEEK = 7 * 24 * 60 * 60 * 1000
def to_millisecond(self, value: int) -> int:
"""
将当前单位时间转换为毫秒数
:return:
"""
return value * self.value