Prechádzať zdrojové kódy

jianye: 处理每月一号时间错误问题

Signed-off-by: binren <zhangbr@elab-plus.com>
binren 4 rokov pred
rodič
commit
5798c55c73
2 zmenil súbory, kde vykonal 13 pridanie a 13 odobranie
  1. 1 1
      jianye_report.py
  2. 12 12
      report_public_funs_utils.py

+ 1 - 1
jianye_report.py

@@ -382,7 +382,7 @@ class JianYeReport(object):
 
     def get_brand_content(self, content, brand_table_one):
 
-        content = content.format(rpfu.get_montho_day(),
+        content = content.format(rpfu.get_month_day(),
                                  brand_table_one[0], brand_table_one[1], brand_table_one[2], brand_table_one[3],
                                  brand_table_one[4], brand_table_one[5],
                                  brand_table_one[6], brand_table_one[8], brand_table_one[10], brand_table_one[11],

+ 12 - 12
report_public_funs_utils.py

@@ -9,15 +9,15 @@ class ReportPublicFunsUtils:
         :param type 1 :y m d 2: y m d : s m m
         :return:
         """
-        now_time = datetime.datetime.now()
-        year = now_time.year
-        month = now_time.month
+        pre_day = ReportPublicFunsUtils.before_day()
+        year = pre_day.year
+        month = pre_day.month
         month = str(month) if month > 9 else '0' + str(month)
         first_day_of_month = str(year) + '-' + month
         if type:
-            return [first_day_of_month + '-01 00:00:00', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d %M:%I:%S')]
+            return [first_day_of_month + '-01 00:00:00', pre_day.strftime('%Y-%m-%d %M:%I:%S')]
         else:
-            return [first_day_of_month + '-01', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d')]
+            return [first_day_of_month + '-01', pre_day.strftime('%Y-%m-%d')]
 
     @staticmethod
     def before_day():
@@ -40,16 +40,16 @@ class ReportPublicFunsUtils:
             return ['2020-02-18', ReportPublicFunsUtils.before_day().strftime('%Y-%m-%d')]
 
     @staticmethod
-    def get_montho_day():
-        now = datetime.datetime.now()
-        month = now.month
-        day = now.day - 1
+    def get_month_day():
+        pre_time = ReportPublicFunsUtils.before_day()
+        month = pre_time.month
+        day = pre_time.day
         return '{}月{}日'.format(month, day)
 
     @staticmethod
     def get_month():
-        now = datetime.datetime.now()
-        return str(now.month)
+        pre_time = ReportPublicFunsUtils.before_day()
+        return str(pre_time.month)
 
     @staticmethod
     def get_pre_day():
@@ -74,4 +74,4 @@ class ReportPublicFunsUtils:
 
 
 if __name__ == '__main__':
-    print(ReportPublicFunsUtils.get_prd_day())
+    print(ReportPublicFunsUtils.get_time_range_month())