64 lines
1.7 KiB
Python
64 lines
1.7 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import datetime
|
|
import time
|
|
|
|
|
|
def str_time():
|
|
return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
|
|
|
|
|
|
def bizdate(day):
|
|
# 获取当前日期
|
|
current_date = datetime.date.today()
|
|
# 计算前一天的日期
|
|
previous_date = current_date - datetime.timedelta(days=day)
|
|
# 格式化日期输出
|
|
return previous_date.strftime('%Y%m%d')
|
|
|
|
def biz_date(day):
|
|
# 获取当前日期
|
|
current_date = datetime.date.today()
|
|
# 计算前一天的日期
|
|
previous_date = current_date - datetime.timedelta(days=day)
|
|
# 格式化日期输出
|
|
return previous_date.strftime('%Y-%m-%d')
|
|
|
|
def t_month(day):
|
|
# 获取当前日期
|
|
current_date = datetime.date.today()
|
|
# 计算前一天的日期
|
|
previous_date = current_date - datetime.timedelta(days=day)
|
|
# 格式化日期输出
|
|
return previous_date.strftime('%Y%m00')
|
|
|
|
|
|
def get_ltv_day():
|
|
day=(1, 2, 3, 4, 5, 6, 7, 14, 30, 60, 90, 150, 300)
|
|
return ','.join(["'"+bizdate(i)+"'" for i in day])
|
|
|
|
def get_parameter():
|
|
return {
|
|
'${bizdate}': bizdate(1),
|
|
'${biz-date}': biz_date(1),
|
|
'${t_month}': t_month(1),
|
|
'${intra_day}': bizdate(0),
|
|
'${intra-day}': biz_date(0),
|
|
'${30_days_later}': bizdate(30),
|
|
'${60_days_later}': bizdate(60),
|
|
'${300_days_later}': bizdate(301),
|
|
'${ltv_day}': get_ltv_day(),
|
|
}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# hhh = {
|
|
# '${bizdate}': bizdate(1),
|
|
# '${t_month}': t_month(1),
|
|
# '${intra_day}': bizdate(0),
|
|
# '${30_days_later}': bizdate(30),
|
|
# '${300_days_later}': bizdate(301)
|
|
# }
|
|
print(get_ltv_day())
|