123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import datetime
- class ReportPublicFunsUtils:
- @staticmethod
- def get_time_range_month(type=None):
- """
- 获取当月一号到当前时间的时间区间
- :param type 1:y m d 2: y m d : s m m
- :return:
- """
- now_time = datetime.datetime.now()
- first_day_of_month = datetime.datetime.now().strftime('%Y-%M')
- if not type:
- return [first_day_of_month + '-01 00:00:00', now_time.strftime('%Y-%m-%d %M:%I:%S')]
- else:
- return [first_day_of_month + '-01', now_time.strftime('%Y-%m-%d')]
- @staticmethod
- def get_prd_day(type=None):
- now_time = datetime.datetime.now()
- pre_time = now_time + datetime.timedelta(days=-1)
- now_time = now_time + datetime.timedelta(days=-1)
- if type:
- return [pre_time.strftime('%Y-%m-%d %M:%I:%S'), now_time.strftime('%Y-%m-%d %M:%I:%S')]
- else:
- repr([pre_time.strftime('%Y-%m-%d'), now_time.strftime('%Y-%m-%d')])
- @staticmethod
- def get_all_time_data_range(type=None):
- now_time = datetime.datetime.now()
- pre_time = now_time + datetime.timedelta(days=-9999)
- if not type:
- return [pre_time.strftime('%Y-%m-%d %M:%I:%S'), now_time.strftime('%Y-%m-%d %M:%I:%S')]
- else:
- return [pre_time.strftime('%Y-%m-%d'), now_time.strftime('%Y-%m-%d')]
- @staticmethod
- def get_montho_day():
- now = datetime.datetime.now()
- month = now.month
- day = now.day
- return '{}月{}日'.format(month, day)
- @staticmethod
- def add(a=None, b=None):
- """
- 求和
- :param a:
- :param b:
- :return:
- """
- if a and b:
- return a + b
- elif a and not b:
- return a
- elif b and not a:
- return b
- return 0
- if __name__ == '__main__':
- print(ReportPublicFunsUtils.get_montho_day())
|