示例#1
0
def last_day_of_month(any_day):
    """
    获取获得一个月中的最后一天
    :param any_day: 任意日期
    :return: string
    """
    next_month = any_day.replace(day=28) + datetime.timedelta(
        days=4)  # this will never fail
    return next_month - datetime.timedelta(days=next_month.day)
def next_business_day(x):
    if x == '':
        ONE_DAY = datetime.timedelta(days=1)
        HOLIDAYS_US = holidays.US()
        next_day = datetime.date.today() + ONE_DAY
        while next_day.weekday() in holidays.WEEKEND or next_day in HOLIDAYS_US:
            next_day += ONE_DAY
        return next_day
    else:
        ONE_DAY = datetime.timedelta(days=x)
        HOLIDAYS_US = holidays.US()
        next_day = datetime.today() + ONE_DAY
        while next_day.weekday() in holidays.WEEKEND or next_day in HOLIDAYS_US:
            next_day += ONE_DAY
        return next_day
示例#3
0
def next_business_day():
    ONE_DAY = datetime.timedelta(days=1)
    HOLIDAYS_US = holidays.US()
    global next_day
    next_day = datetime.date.today() + ONE_DAY
    while next_day.weekday() in holidays.WEEKEND or next_day in HOLIDAYS_US:
        next_day += ONE_DAY
    return next_day
示例#4
0
 def getdatelist(self, year, month, day=1):
     date_list = []
     # begin_date = (datetime.datetime.now() - datetime.timedelta(days=30)).strftime("%Y-%m-%d")
     begin_date = datetime.datetime.strftime(
         datetime.datetime(year, month, day), "%Y-%m-%d")
     # begin_date = datetime.datetime(2020, 2, 1)
     begin_date = datetime.datetime.strptime(begin_date, "%Y-%m-%d")
     if year == datetime.date.today().year and month == datetime.date.today(
     ).month:
         end_date = datetime.datetime.strptime(
             time.strftime('%Y-%m-%d', time.localtime(time.time())),
             "%Y-%m-%d")
     else:
         end_date = last_day_of_month(begin_date)
     while begin_date <= end_date:
         date_str = begin_date.strftime("%Y-%m-%d")
         date_list.append(date_str)
         begin_date += datetime.timedelta(days=1)
     #print(date_list)
     return date_list
def business_day():
    ONE_DAY = datetime.timedelta(days=0)
    HOLIDAYS_US = holidays.US()
    # next day = today because renaming variables is hard
    next_day = datetime.date.today() + ONE_DAY
    while next_day.weekday() in holidays.WEEKEND or next_day in HOLIDAYS_US:
        next_day += ONE_DAY
        day = str(next_day.day)
        d1 = " "
        c1 = ","
        month = str(next_day.month)
        yr = str(next_day.year)
        if month == "1" or "01":
            month1 = "January"
        elif month == "2" or "02":
            month1 = "February"
        elif month == "3" or "03":
            month1 = "March"
        elif month == "4" or "04":
            month1 = "April"
        elif month == "5" or "05":
            month1 = "May"
        elif month == "6" or "06":
            month1 = "June"
        elif month == "7" or "07":
            month1 = "July"
        elif month == "8" or "08":
            month1 = "August"
        elif month == "9" or "09":
            month1 = "September"
        elif month == "10" or "10":
            month1 = "October"
        elif month == "11" or "11":
            month1 = "November"
        else:
            month1 = "December"
    reformatted: str = month1 + d1 + day + c1 + d1 + yr
    return reformatted
示例#6
0
 def last_day_of_month(self, date):
     next_month = date.replace(day=28) + datetime.timedelta(days=4)
     return next_month - datetime.timedelta(days=next_month.day)
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

import keyboard
from selenium import webdriver
from _datetime import datetime
import datetime
import holidays

ONE_DAY = datetime.timedelta(days=1)
HOLIDAYS_US = holidays.US()


def next_business_day():
    next_day = datetime.date.today() + ONE_DAY
    global reformatted
    reformatted = ""
    while next_day.weekday() in holidays.WEEKEND or next_day in HOLIDAYS_US:
        next_day += ONE_DAY
        day = str(next_day.day)
        d1 = "/"
        month = str(next_day.month)
        yr = str(next_day.year)
        asd = month + d1 + day + d1 + yr
        reformatted = asd
    return reformatted


def tcdj1():