Example #1
0
def isOpen(today):
    tommorrow = today + datetime.timedelta(days=1)
    yesterday = today - datetime.timedelta(days=1)
    if today.weekday() >= 5 or jholiday.holiday_name(date=today) is not None or (jholiday.holiday_name(date=tommorrow) is not None and jholiday.holiday_name(date=yesterday)) or (today.month==1 and today.day <= 3) or (today.month==12 and today.day == 31) :
        return False
    else:
        return True
def dayType(title):
    if jholiday.holiday_name(date=title) is not None:
        dayP = jholiday.holiday_name(date=title).encode('utf8')
        dayT = "holiday"
    else:
        dayP = title.strftime('%a')
        if title.weekday() not in [5, 6]:
            dayT = "weekday"
        else:
            dayT = "weekend"
    return dayP, dayT
Example #3
0
def isOpen(today):
    tommorrow = today + datetime.timedelta(days=1)
    yesterday = today - datetime.timedelta(days=1)
    if today.weekday() >= 5 or jholiday.holiday_name(
            date=today) is not None or (
                jholiday.holiday_name(date=tommorrow) is not None
                and jholiday.holiday_name(date=yesterday)) or (
                    today.month == 1
                    and today.day <= 3) or (today.month == 12
                                            and today.day == 31):
        return False
    else:
        return True
Example #4
0
def DataDate():
    '''
    出力データの日付設定 AM PM で日付を変更
    営業日のみを出力
    '''
    d = datetime.date.today()
    t1 = datetime.datetime.now().strftime('%H%M')
    t2 = datetime.time(15,00).strftime('%H%M')
    add_d = datetime.timedelta(days = 1)

    # 午後のとき、翌日分に
    if t1 < t2:
        pass
    elif t1 > t2:
        d = d + add_d

    while True:
        # 平日に修正
        while d.weekday() >= 5:
            d = d + add_d
        
        #祝日のとき、翌日へ
        if jholiday.holiday_name(date = d):
            d = d + add_d
        else:
            break
        
    d = d.strftime('%Y%m%d')
    
    return d
Example #5
0
def market_check():
	time_now = time.localtime()
	#print time_now.tm_year,time_now.tm_mon,time_now.tm_mday
	now_hour = time_now.tm_hour + time_now.tm_min/60.0
	if(int(time_now.tm_mon) == 1 and int(time_now.tm_mday) < 4):
		#print "Oshougatu"
		return 0
	if(int(time_now.tm_mon) == 12 and int(time_now.tm_mday) == 31):
		#print "oomisoka"
		return 0
	#print now_hour
	if(time_now.tm_wday >= 5):
		#print "Close"
		return 0
	if(jholiday.holiday_name(time_now.tm_year,time_now.tm_mon,time_now.tm_mday)):
		#print "Close"
		return 0
	if(now_hour >= MarketClose):
		#print "Close"
		return 0
	if(now_hour >= MarketBreakStart and now_hour < MarketBreakEnd):
		#print "Break"
		return 2
	if(now_hour >= MarketOpen):
		#print "Open"
		return 1
	if(now_hour < MarketOpen):
		#print "Open"
		return 3
	return 0
Example #6
0
def holiday_list(y, m, d):
    # 今日
    today = datetime.date.today()
    # 開始日
    start_date = datetime.date(y, m, d)

    # 日数の計算
    date_count = today - start_date

    # 休日判別処理
    li = []
    day = start_date
    count_holiday = 0
    count_sun_stu = 0
    while today > day:
        date_y = int(day.strftime('%Y'))
        date_m = int(day.strftime('%m'))
        date_d = int(day.strftime('%d'))
        date_str = day.strftime('%Y%m%d')
        # print jholiday.holiday_name(date_y,date_m,date_d)
        if jholiday.holiday_name(date_y, date_m, date_d):
            li.append(date_str)
            count_holiday += 1
        elif day.weekday() == 5 and 6:
            li.append(date_str)
            count_sun_stu += 1
        day = day + datetime.timedelta(1)

    #print li
    print("day: %s" % date_count)
    print("holiday: %s" % count_holiday)
    print("sun_stu: %s" % count_sun_stu)

    return li
def doniti(date):
    if date.weekday() >= 5:
        return 1
    else:
        if jholiday.holiday_name(
                year=date.year, month=date.month, day=date.day) != None:
            return 1
        else:
            return 0
Example #8
0
def hook(bot, status):
    m = _re_date.search(unicodedata.normalize('NFKC', status.text))
    if not m:
        return False

    nengo = m.group(1)
    if m.group(2) == u'元':
        year = 1
    else:
        year = int(m.group(2))
    month = int(m.group(3))
    day = int(m.group(4))

    try:
        if year == 0:
            raise Exception()
        if nengo == u'平成':
            #1989年1月8日から
            year += 1988
            if year == 1989 and month == 1 and day < 8:
                raise Exception()
        elif nengo == u'昭和':
            #1926年12月25日から1989年1月7日まで
            year += 1925
            if year == 1926 and (month < 12 or day < 25):
                raise Exception()
            if year == 1989 and (month > 1 or day > 7):
                raise Exception()
        elif nengo == u'大正':
            #1912年7月30日から1926年12月25日まで
            year += 1911
            if year == 1912 and (month < 7 or (month == 7 and day < 30)):
                raise Exception()
            if year == 1926 and month == 12 and day > 25:
                raise Exception()
        elif nengo == u'明治':
            #1868年1月25日から1912年7月30日まで
            year += 1867
            if year == 1868 and month == 1 and day < 25:
                raise Exception()
            if year == 1912 and (month > 7 or (month == 7 and day > 30)):
                raise Exception()
        date = datetime.date(year, month, day)
        hname = holiday_name(year, month, day)
        weekday = date.weekday()

        if hname:
            text = u'%d年%d月%d日は%s曜日、%sです。' % (year, month, day,
                                              _week_name[weekday], hname)
        else:
            text = u'%d年%d月%d日は%s曜日です。' % (year, month, day,
                                           _week_name[weekday])
    except Exception, e:
        print e
        text = u'そんな日付は存在しません。'
Example #9
0
def get_business_days(year, month, exclude=None):
    business_days = 0
    for i in range(1, 32):
        try:
            this_date = datetime.date(int(year), int(month), i)
        except(ValueError):
            break
        if this_date.weekday() < 5 and jholiday.holiday_name(int(year), int(month), i) is None: # Monday == 0, Sunday == 6
            if exclude and this_date.strftime("%Y/%m/%d") not in exclude:
                business_days += 1
    return business_days
Example #10
0
def is_sat_sun_holiday(date, color):
    day_of_the_week_index = int(date.strftime('%w'))
    if jholiday.holiday_name(date.year, date.month, date.day) is not None:
        return 'red'
    else:
        if day_of_the_week_index == 6:
            return 'blue'
        elif day_of_the_week_index == 0:
            return 'red'
        else:
            return color
Example #11
0
def marekt_holiday(dt):
	if(int(dt.month) == 1 and int(dt.day) < 4):
		#print "Oshougatu"
		return 1
	if(int(dt.month) == 12 and int(dt.day) == 31):
		#print "oomisoka"
		return 1
	if(jholiday.holiday_name(date = dt)):
		#print "Close"
		return 1
	return 0
Example #12
0
def hook(bot, status):
    m = _re_date.search(unicodedata.normalize('NFKC',status.text))
    if not m:
        return False

    nengo = m.group(1)
    if m.group(2)==u'元':
        year = 1
    else:
        year = int(m.group(2))
    month = int(m.group(3))
    day = int(m.group(4))

    try:
        if year==0:
            raise Exception()
        if nengo==u'平成':
            #1989年1月8日から
            year += 1988
            if year==1989 and month==1 and day<8:
                raise Exception()
        elif nengo==u'昭和':
            #1926年12月25日から1989年1月7日まで
            year += 1925
            if year==1926 and (month<12 or day<25):
                raise Exception()
            if year==1989 and (month>1 or day>7):
                raise Exception()
        elif nengo==u'大正':
            #1912年7月30日から1926年12月25日まで
            year += 1911
            if year==1912 and (month<7 or (month==7 and day<30)):
                raise Exception()
            if year==1926 and month==12 and day>25:
                raise Exception()
        elif nengo==u'明治':
            #1868年1月25日から1912年7月30日まで
            year += 1867
            if year==1868 and month==1 and day<25:
                raise Exception()
            if year==1912 and (month>7 or (month==7 and day>30)):
                raise Exception()
        date = datetime.date(year, month, day)
        hname = holiday_name(year, month, day)
        weekday = date.weekday()
        
        if hname:
            text = u'%d年%d月%d日は%s曜日、%sです。' % (year, month, day, _week_name[weekday], hname)
        else:
            text = u'%d年%d月%d日は%s曜日です。' % (year, month, day, _week_name[weekday])
    except Exception, e:
        print e
        text = u'そんな日付は存在しません。'
Example #13
0
def _is_holiday(date):
    """休日か否かを返す"""
    weekday = date.weekday()
    if weekday == 5 or weekday == 6:
        return True
    if date.month == 8 and 14 <= date.day and date.day <= 16:
        return True
    if date.month == 12 and date.day >= 29:
        return True
    if date.month == 1 and date.day <= 3:
        return True
    return holiday_name(date=date)
Example #14
0
def _is_holiday(date):
    """休日か否かを返す"""
    weekday = date.weekday()
    if weekday==5 or weekday==6:
        return True
    if date.month==8 and 14<=date.day and date.day<=16:
        return True
    if date.month==12 and date.day>=29:
        return True
    if date.month==1 and date.day<=3:
        return True
    return holiday_name(date=date)
Example #15
0
def is_sat_sun_holiday(date, color):
    royalblue = 'FF4169E1'
    tomato = 'FFFF6347'
    day_of_the_week_index = int(date.strftime('%w'))
    if jholiday.holiday_name(date.year, date.month, date.day) is not None:
        return tomato
    else:
        if day_of_the_week_index == 6:
            return royalblue
        elif day_of_the_week_index == 0:
            return tomato
        else:
            return color
Example #16
0
def get_business_days(year, month, exclude=None):
    from eb.models import Holiday
    business_days = []
    eb_holidays = [holiday.date for holiday in Holiday.objects.public_all()]
    for i in range(1, 32):
        try:
            this_date = datetime.date(int(year), int(month), i)
        except ValueError:
            break
        if this_date.weekday() < 5 and jholiday.holiday_name(int(year), int(month), i) is None:
            # Monday == 0, Sunday == 6
            if exclude and this_date.strftime("%Y/%m/%d") not in exclude:
                business_days.append(this_date)
            elif exclude is None:
                business_days.append(this_date)
    return [date for date in business_days if date not in eb_holidays]
Example #17
0
    def holiday_list(self, start, end):
        start_date = datetime.date(start, 1, 1)
        end_date = datetime.date(end, 1, 1)
        # 日数の計算
        date_count = end_date - start_date
        self.__dict__['count'] = date_count

        # 休日判別処理
        li = []
        li_all_holiday = []
        li_holiday = []
        li_sun_stu = []
        day = start_date
        while end_date > day:
            li.append(day)
            date_y = int(day.strftime('%Y'))
            date_m = int(day.strftime('%m'))
            date_d = int(day.strftime('%d'))
            date_str = day.strftime('%Y%m%d')
            # print jholiday.holiday_name(date_y,date_m,date_d)
            if jholiday.holiday_name(date_y, date_m, date_d):
                li_all_holiday.append(day)
                li_holiday.append(day)
            elif day.weekday() == 5 or day.weekday() == 6:
                li_all_holiday.append(day)
                li_sun_stu.append(day)
            day = day + datetime.timedelta(1)

        # print li
        print ('day: %s' % date_count)
        print ('holiday: %s' % len(li_holiday))
        print ('sun_stu: %s' % len(li_sun_stu))

        # 全日のリスト
        self.__dict__['all'] = li
        # 全休日のリスト
        self.__dict__['all_holiday'] = li_all_holiday
        # 祝日のリスト
        self.__dict__['holiday'] = li_holiday
        # 土日のリスト
        self.__dict__['sun_stu'] = li_sun_stu
        # 平日のリスト
        self.__dict__['weekday'] = set(li) - set(li_all_holiday)
Example #18
0
def count_workdays(start, end):
    """
    指定した開始日から終了日の平日(就業日)をカウントする
    start, end:'yyyy/mm/dd'の文字列形式
    """
    start_date = datetime.datetime.strptime(start, '%Y/%m/%d')
    end_date = datetime.datetime.strptime(end, '%Y/%m/%d')
    one_day = datetime.timedelta(days=1)
    count = 0
    while start_date != end_date+one_day:
        print(start_date.strftime('%Y/%m/%d'), end='')
        if start_date.weekday() not in\
            (calendar.SATURDAY, calendar.SUNDAY)\
            and jholiday.holiday_name(start_date.year,\
            start_date.month, start_date.day) is None:
            count += 1
            print('')
        else:
            print('(休)')
        

        start_date += one_day
    return count
def is_holiday(date):#datetime型で引数を取る
  if jholiday.holiday_name(date.year,date.month,date.day) is not None or date.weekday() > 5:
    return True
  return False
Example #20
0
    def tue_mtg(self, start_time, end_time, day_name, room_name, room_num):

        """
        鈴木の予約: 定例(火曜11:00-12:00)

        """

        for d in range(first.day, last.day + 1, 1):  # 月の初めから最後までループ
            iter_date = today + relativedelta(months=target_month) - datetime.timedelta(
                days=get_month.day - d)  # iが増えることで日も増える

            # 祝日セット
            holiday_name = jholiday.holiday_name(date=iter_date)

            """
            datetimeから曜日を取得
            weekdayと曜日の対応
            0: 月, 1: 火, 2: 水, 3: 木, 4: 金, 5: 土, 6: 日

            """
            if holiday_name is None and iter_date.weekday() == 1: # 1は火曜日


                try:
                    driver.implicitly_wait(10)
                    driver.find_element_by_link_text(str(d)).click()  # 日付指定

                    # 会議室を選択
                    driver.find_element_by_xpath(room_num).click()

                    # 時間選択
                    start_time_element = driver.find_element_by_name('StartTime')
                    select_start_time = Select(start_time_element)
                    select_start_time.select_by_value(start_time)
                    end_time_element = driver.find_element_by_name('EndTime')
                    select_end_time = Select(end_time_element)
                    select_end_time.select_by_value(end_time)
                    # 目的選択
                    purpose = driver.find_element_by_name('PurposeCode')
                    select_purpose = Select(purpose)
                    select_purpose.select_by_value('1')
                    driver.find_element_by_name("NumberOfUsers").send_keys('10')
                    # 予約ボタン押下
                    driver.find_element_by_xpath(
                        '//button[@class="btn blue submit-form-new"][@type="button"]').click()
                    driver.implicitly_wait(10)

                    # ダブルブッキングした場合
                    alert_msg = driver.find_element_by_xpath('//section[@class="alert error active"]')
                    if alert_msg:
                        print(str(iter_date) + " " + day_name + " " + room_name + str(start_time) + '-' + str(
                            end_time) + ' は既に取られています')
                        driver.find_element_by_xpath('//div[@class="btnCircle close"][@id="close-entry"]').click()
                        driver.implicitly_wait(10)
                    else:
                        print(str(iter_date) + " " + day_name + " " + room_name + str(start_time) + '-' + str(
                            end_time) + ' は予約完了')

                except selenium.common.exceptions.UnexpectedAlertPresentException:
                    print(str(iter_date) + " " + day_name + "  " + str(start_time) + '-' + str(end_time) + ' は祝日です')
                except NoSuchElementException:
                    pass
                except ElementNotInteractableException:
                    print("クリックできませんでした。")
Example #21
0
)
a = cur.fetchall()
if a[0][0] == 0:
    cur.execute(
        """CREATE TABLE day_data(year int,month int,day int,date text,isholi int,ispreholi int,name1 int,name2 int,name3 int,primary key (month,day));"""
    )
    for ele in calendar.Calendar().itermonthdays2(2016, 5):
        if ele[0] == 0:
            continue
        cur.execute(
            """INSERT INTO day_data(year,month,day,date,isholi,ispreholi) VALUES(2016,5,{0},"{1}",0,0);"""
            .format(ele[0], date_conv_dict[ele[1]]))
    cur.execute("""SELECT month,day,date FROM day_data;""")
    for month, day, date in cur.fetchall():
        print("month {0}, day {1}".format(month, day))
        if (jholiday.holiday_name(
                2016, month, day)) != None or date == "Sat" or date == "Sun":
            #print('{0}-{1} = holiday'.format(month,day))
            cur.execute(
                """UPDATE day_data SET isholi=1 WHERE day={0};""".format(day))
            cur.execute(
                """UPDATE day_data SET ispreholi=1 WHERE day={0};""".format(
                    day - 1))

#create each member's database
cur.execute(
    """select count(*) from sqlite_master where type='table' and name='mem_data';"""
)
a = cur.fetchall()
if a[0][0] == 0:
    cur.execute(
        """CREATE TABLE mem_data(id integer primary key,name text,workcnt int,worktime int);"""
def is_holiday(date):
    if is_saturday_or_sunday(date) or \
            jholiday.holiday_name(date.year, date.month, date.day):
       return True
    return False
Example #23
0
member = config.get('member','member').split(",")


#create database and distinguish holiday,before holiday
cur.execute("""select count(*) from sqlite_master where type='table' and name='day_data';""")
a = cur.fetchall()
if a[0][0] == 0 :
    cur.execute("""CREATE TABLE day_data(year int,month int,day int,date text,isholi int,ispreholi int,name1 int,name2 int,name3 int,primary key (month,day));""")
    for ele in calendar.Calendar().itermonthdays2(2016,5):
        if ele[0] == 0:
            continue
        cur.execute("""INSERT INTO day_data(year,month,day,date,isholi,ispreholi) VALUES(2016,5,{0},"{1}",0,0);""".format(ele[0],date_conv_dict[ele[1]]))
    cur.execute("""SELECT month,day,date FROM day_data;""")
    for month,day,date in cur.fetchall():
        print("month {0}, day {1}".format(month,day))
        if (jholiday.holiday_name(2016,month,day)) != None or date == "Sat" or date == "Sun":
            #print('{0}-{1} = holiday'.format(month,day))
            cur.execute("""UPDATE day_data SET isholi=1 WHERE day={0};""".format(day))
            cur.execute("""UPDATE day_data SET ispreholi=1 WHERE day={0};""".format(day-1))

#create each member's database
cur.execute("""select count(*) from sqlite_master where type='table' and name='mem_data';""")
a = cur.fetchall()
if a[0][0] == 0 :
    cur.execute("""CREATE TABLE mem_data(id integer primary key,name text,workcnt int,worktime int);""")
    for i in range(len(member)):
        cur.execute("""INSERT INTO mem_data(name,workcnt,worktime) VALUES('{0}',0,0);""".format(member[i]))

#create req config file
fw = open("req.conf","w")
fw.write("[request]\n")
Example #24
0
    return first_date, last_date


first, last = get_dates(target_month)

for i in range(first.day, last.day + 1, 1):

    iter_date = today + relativedelta(
        months=target_month) - datetime.timedelta(days=get_month.day - i)
    """
    datetimeから曜日を取得
    weekdayと曜日の対応     
    0: 月, 1: 火, 2: 水, 3: 木, 4: 金, 5: 土, 6: 日
    """

    holiday_name = jholiday.holiday_name(date=iter_date)

    if holiday_name is None:

        if iter_date.weekday() == 0:
            print(str(iter_date) + ' is Monday')
        elif iter_date.weekday() == 1:
            print(str(iter_date) + ' is Tuesday')
        elif iter_date.weekday() == 2:
            print(str(iter_date) + ' is Wednesday')
        elif iter_date.weekday() == 3:
            print(str(iter_date) + ' is Thursday')
        elif iter_date.weekday() == 4:
            print(str(iter_date) + ' is Friday')
Example #25
0
    def everyday_mtg(self, start_time, end_time, room_name, room_num):

        """"
      毎日同じ時間に同じ場所を予約する

        """

        for d in range(first.day, last.day + 1, 1):  # 月の初めから最後までループ

            iter_date = today + relativedelta(months=target_month) - datetime.timedelta(
                days=get_month.day - d)  # dが増えることで日も増える

            holiday_name = jholiday.holiday_name(date=iter_date)
            """
            datetimeから曜日を取得
            weekdayと曜日の対応     
            0: 月, 1: 火, 2: 水, 3: 木, 4: 金, 5: 土, 6: 日
            """

            try:
                if holiday_name is None and not iter_date.weekday() == 5 and not iter_date.weekday() == 6:  # 祝日以外、平日のとき

                    if iter_date.weekday() == 0:
                        day_name = '(月)'
                    elif iter_date.weekday() == 1:
                        day_name = '(火)'
                    elif iter_date.weekday() == 2:
                        day_name = '(水)'
                    elif iter_date.weekday() == 3:
                        day_name = '(木)'
                    elif iter_date.weekday() == 4:
                        day_name = '(金)'

                    driver.find_element_by_link_text(str(d)).click()
                    driver.implicitly_wait(10)
                    # 会議室選択
                    driver.find_element_by_xpath(room_num).click()
                    # 時間選択
                    start_time_element = driver.find_element_by_name('StartTime')
                    select_start_time = Select(start_time_element)
                    select_start_time.select_by_value(start_time)
                    end_time_element = driver.find_element_by_name('EndTime')
                    select_end_time = Select(end_time_element)
                    select_end_time.select_by_value(end_time)
                    # 目的選択
                    purpose = driver.find_element_by_name('PurposeCode')
                    select_purpose = Select(purpose)
                    select_purpose.select_by_value('1')
                    driver.find_element_by_name("NumberOfUsers").send_keys('10')
                    # 予約ボタン押下
                    driver.find_element_by_xpath('//button[@class="btn blue submit-form-new"][@type="button"]').click()
                    driver.implicitly_wait(10)

                    # ダブルブッキングした場合
                    alert_msg = driver.find_element_by_xpath('//section[@class="alert error active"]')

                    if alert_msg:
                        print(str(iter_date) + " " + day_name + " " + room_name + " " + str(start_time) + '-' + str(
                            end_time) + ' は既に取られています')
                        driver.find_element_by_xpath('//div[@class="btnCircle close"][@id="close-entry"]').click()
                        driver.implicitly_wait(10)
                    else:
                        print(str(iter_date) + " " + day_name + " " + room_name + " " + str(start_time) + '-' + str(
                            end_time) + ' の予約完了')

            except selenium.common.exceptions.UnexpectedAlertPresentException:
                print(str(iter_date) + " " + day_name + " " + str(start_time) + '-' + str(end_time) + ' は祝日です')
            except NoSuchElementException:
                pass
            except ElementNotInteractableException:
                print("クリックできませんでした。")
            except selenium.common.exceptions.StaleElementReferenceException:
                pass
def oms_mtg():
    """"
    試験朝会用の予約

    """

    for d in range(first.day, last.day + 1, 1):  # 月の初めから最後までループ

        iter_date = today + relativedelta(
            months=target_month) - datetime.timedelta(
                days=get_month.day - d)  # iが増えることで日も増える

        holiday_name = jholiday.holiday_name(date=iter_date)
        """
        datetimeから曜日を取得
        weekdayと曜日の対応     
        0: 月, 1: 火, 2: 水, 3: 木, 4: 金, 5: 土, 6: 日
        """
        """
        属性の値 data-timeline = "x" ← 以下から該当する数字をxに記入する

        1: 応接室, 2: 大会議室, 3: SouthTerrace, 4: Core-A 6: 事業部長会議室 
        7: N-A, 8: N-B, 9: N-C, 10: N-D, 11:N-E, 12: N-F 
        13: S-A, 14: S-B, 15: S-C, 16: S-D, 17: S-E
        """
        try:
            if holiday_name is None and not iter_date.weekday(
            ) == 5 and not iter_date.weekday() == 6:  #祝日以外、平日のとき
                """
                    N-E 平日 9:30-11:00を予約
    
                """
                start_time = '09:30'  # ここを変える
                end_time = '11:00'  # ここを変える

                if iter_date.weekday() == 0:
                    day_name = '(月)'
                elif iter_date.weekday() == 1:
                    day_name = '(火)'
                elif iter_date.weekday() == 2:
                    day_name = '(水)'
                elif iter_date.weekday() == 3:
                    day_name = '(木)'
                elif iter_date.weekday() == 4:
                    day_name = '(金)'

                driver.find_element_by_link_text(str(d)).click()
                driver.implicitly_wait(10)
                driver.find_element_by_xpath(
                    '//div[@class="tl ui-selectee"][@data-timeline="2"]'
                ).click()  # 大会議室を選択 ここを変える
                # 時間選択
                start_time_element = driver.find_element_by_name('StartTime')
                select_start_time = Select(start_time_element)
                select_start_time.select_by_value(start_time)
                end_time_element = driver.find_element_by_name('EndTime')
                select_end_time = Select(end_time_element)
                select_end_time.select_by_value(end_time)
                # 目的選択
                purpose = driver.find_element_by_name('PurposeCode')
                select_purpose = Select(purpose)
                select_purpose.select_by_value('1')
                driver.find_element_by_name("NumberOfUsers").send_keys('10')
                # 予約ボタン押下
                driver.find_element_by_xpath(
                    '//button[@class="btn blue submit-form-new"][@type="button"]'
                ).click()
                driver.implicitly_wait(10)

                # ダブルブッキングした場合
                alert_msg = driver.find_element_by_xpath(
                    '//section[@class="alert error active"]')

                if alert_msg:
                    print(
                        str(iter_date) + " " + day_name + " " + '大会議室 ' +
                        str(start_time) + '-' + str(end_time) +
                        ' is already taken.')
                    driver.find_element_by_xpath(
                        '//div[@class="btnCircle close"][@id="close-entry"]'
                    ).click()
                    driver.implicitly_wait(10)
                else:
                    print(
                        str(iter_date) + " " + day_name + " " + '大会議室 ' +
                        str(start_time) + '-' + str(end_time) + ' is booked.')

        except selenium.common.exceptions.UnexpectedAlertPresentException:
            print("エラーが発生しました。")
        except NoSuchElementException:
            print("属性が見つかりませんでした。")
        except ElementNotInteractableException:
            print("クリックできませんでした。")
def my_mtg():
    """"
    個人用の予約

    """

    for d in range(first.day, last.day + 1, 1):  # 月の初めから最後までループ

        iter_date = today + relativedelta(
            months=target_month) - datetime.timedelta(
                days=get_month.day - d)  # iが増えることで日も増える
        """
        datetimeから曜日を取得
        weekdayと曜日の対応     
        0: 月, 1: 火, 2: 水, 3: 木, 4: 金, 5: 土, 6: 日
        """
        """
        属性の値 data-timeline = "x" ← 以下から該当する数字をxに記入する
    
        1: 応接室, 2: 大会議室, 3: SouthTerrace, 4: Core-A 6: 事業部長会議室 
        7: N-A, 8: N-B, 9: N-C, 10: N-D, 11:N-E, 12: N-F 
        13: S-A, 14: S-B, 15: S-C, 16: S-D, 17: S-E
        """
        holiday_name = jholiday.holiday_name(date=iter_date)

        if holiday_name is None:

            if iter_date.weekday() == 1:  #火曜日だったら以下を予約
                """
                             大会議室 火曜 11:00-12:00を予約
        
                """
                start_time = '11:00'
                end_time = '12:00'
                day_name = '(火)'
                try:
                    driver.implicitly_wait(10)
                    driver.find_element_by_link_text(str(d)).click()  # 日付指定
                    driver.find_element_by_xpath(
                        '//div[@class="tl ui-selectee"][@data-timeline="2"]'
                    ).click()  # 二行目(大会議室)を選択
                    # 時間選択
                    start_time_element = driver.find_element_by_name(
                        'StartTime')
                    select_start_time = Select(start_time_element)
                    select_start_time.select_by_value(start_time)
                    end_time_element = driver.find_element_by_name('EndTime')
                    select_end_time = Select(end_time_element)
                    select_end_time.select_by_value(end_time)
                    # 目的選択
                    purpose = driver.find_element_by_name('PurposeCode')
                    select_purpose = Select(purpose)
                    select_purpose.select_by_value('1')
                    driver.find_element_by_name("NumberOfUsers").send_keys(
                        '10')
                    # 予約ボタン押下
                    driver.find_element_by_xpath(
                        '//button[@class="btn blue submit-form-new"][@type="button"]'
                    ).click()
                    driver.implicitly_wait(10)

                    # ダブルブッキングした場合
                    alert_msg = driver.find_element_by_xpath(
                        '//section[@class="alert error active"]')
                    if alert_msg:
                        print(
                            str(iter_date) + " " + day_name + " " + '大会議室 ' +
                            str(start_time) + '-' + str(end_time) +
                            ' is already taken.')
                        driver.find_element_by_xpath(
                            '//div[@class="btnCircle close"][@id="close-entry"]'
                        ).click()
                        driver.implicitly_wait(10)
                    else:
                        print(
                            str(iter_date) + " " + day_name + " " + '大会議室 ' +
                            str(start_time) + '-' + str(end_time) +
                            ' is booked.')

                except selenium.common.exceptions.UnexpectedAlertPresentException:
                    print(
                        str(iter_date) + " " + day_name + " " +
                        str(start_time) + '-' + str(end_time) + ' is holiday.')
                except selenium.common.exceptions.UnexpectedAlertPresentException:
                    print("エラーが発生しました。")
                except NoSuchElementException:
                    print("属性が見つかりませんでした。")
                except ElementNotInteractableException:
                    print("クリックできませんでした。")
                """
                             火曜 14:00-15:00を予約
                
                start_time = '14:00'
                end_time = '15:00'
                driver.implicitly_wait(10)
                try:
                    driver.find_element_by_link_text(str(d)).click()  # 日付指定
                    driver.find_element_by_xpath('//div[@class="tl ui-selectee"][@data-timeline="12"]').click()  # N-Fを選択
                    start_time_element = driver.find_element_by_name('StartTime')
                    select_start_time = Select(start_time_element)
                    select_start_time.select_by_value(start_time)
                    end_time_element = driver.find_element_by_name('EndTime')
                    select_end_time = Select(end_time_element)
                    select_end_time.select_by_value(end_time)
    
                    #目的選択
                    purpose = driver.find_element_by_name('PurposeCode')
                    select_purpose = Select(purpose)
                    select_purpose.select_by_value('1')
                    driver.find_element_by_name("NumberOfUsers").send_keys('10')
                    
                    # 予約ボタン押下
                    driver.find_element_by_xpath('//button[@class="btn blue submit-form-new"][@type="button"]').click()
                    driver.implicitly_wait(10)
                    
                    # ダブルブッキングした場合
                    alert_msg = driver.find_element_by_xpath('//section[@class="alert error active"]')

                    if alert_msg:
                        print(str(iter_date) + " " + day_name + " " + 'SouthTerrace ' + str(start_time) + '-' + str(
                            end_time) + ' is already taken.')
                        driver.find_element_by_xpath('//div[@class="btnCircle close"][@id="close-entry"]').click()
                        driver.implicitly_wait(10)
                    else:
                        print(str(iter_date) + " " + day_name + " " + 'SouthTerrace ' + str(start_time) + '-' + str(
                            end_time) + ' is booked.')

                except selenium.common.exceptions.UnexpectedAlertPresentException:
                     print(str(iter_date) + " " + day_name + " " + str(start_time) + '-' + str(
                    end_time) + ' is holiday.')
                except selenium.common.exceptions.UnexpectedAlertPresentException:
                    print("エラーが発生しました。")
                except NoSuchElementException:
                    print("属性が見つかりませんでした。")
            
                except ElementNotInteractableException:
                    print("クリックできませんでした。")
                """

            elif iter_date.weekday() == 3:  # 木曜だったら以下を予約
                """
                            South Terrace 木曜 16:00-18:00を予約
                """
                start_time = '16:00'
                end_time = '18:00'
                day_name = '(木)'

                try:
                    driver.find_element_by_link_text(str(d)).click()  # 日付指定
                    driver.implicitly_wait(10)  # 見つからないときは、10秒まで待つ
                    driver.find_element_by_xpath(
                        '//div[@class="tl ui-selectee"][@data-timeline="3"]'
                    ).click()  # STを選択

                    # 時間選択
                    start_time_element = driver.find_element_by_name(
                        'StartTime')
                    select_start_time = Select(start_time_element)
                    select_start_time.select_by_value(start_time)
                    end_time_element = driver.find_element_by_name('EndTime')
                    select_end_time = Select(end_time_element)
                    select_end_time.select_by_value(end_time)
                    # 目的選択
                    purpose = driver.find_element_by_name('PurposeCode')
                    select_purpose = Select(purpose)
                    select_purpose.select_by_value('1')
                    driver.find_element_by_name("NumberOfUsers").send_keys(
                        '10')
                    # 予約ボタン押下
                    driver.find_element_by_xpath(
                        '//button[@class="btn blue submit-form-new"][@type="button"]'
                    ).click()
                    driver.implicitly_wait(10)

                    # ダブルブッキングした場合
                    alert_msg = driver.find_element_by_xpath(
                        '//section[@class="alert error active"]')

                    if alert_msg:
                        print(
                            str(iter_date) + " " + day_name + " " +
                            'SouthTerrace ' + str(start_time) + '-' +
                            str(end_time) + ' is already taken.')
                        driver.find_element_by_xpath(
                            '//div[@class="btnCircle close"][@id="close-entry"]'
                        ).click()
                        driver.implicitly_wait(10)
                    else:
                        print(
                            str(iter_date) + " " + day_name + " " +
                            'SouthTerrace ' + str(start_time) + '-' +
                            str(end_time) + ' is booked.')

                except selenium.common.exceptions.UnexpectedAlertPresentException:
                    print(
                        str(iter_date) + " " + day_name + " " +
                        str(start_time) + '-' + str(end_time) + ' is holiday.')
                except selenium.common.exceptions.UnexpectedAlertPresentException:
                    print("エラーが発生しました。")
                except NoSuchElementException:
                    print("属性が見つかりませんでした。")
                except ElementNotInteractableException:
                    print("クリックできませんでした。")
Example #28
0
import calendar
import jholiday
text = calendar.TextCalendar()
text.formatmonth(2016,5)

print (calendar.month(2016,5))

# 0:mon 1:tue 2:wed 3:thu 4:fri 5:sat 6:sun
for ele in calendar.Calendar().itermonthdays2(2016,5):
    print ('({0} and {1})'.format(ele[0],ele[1]))
    if ele[0] == 0:
        continue
    print(jholiday.holiday_name(2016,5,ele[0]))
    print(type(jholiday.holiday_name(2016,5,ele[0])))
Example #29
0
import calendar
import jholiday
text = calendar.TextCalendar()
text.formatmonth(2016, 5)

print(calendar.month(2016, 5))

# 0:mon 1:tue 2:wed 3:thu 4:fri 5:sat 6:sun
for ele in calendar.Calendar().itermonthdays2(2016, 5):
    print('({0} and {1})'.format(ele[0], ele[1]))
    if ele[0] == 0:
        continue
    print(jholiday.holiday_name(2016, 5, ele[0]))
    print(type(jholiday.holiday_name(2016, 5, ele[0])))