Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Fixed a bug that does not start or stop at 0 o'clock. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions code/ec2-scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import boto3
import datetime
import json
import re
from urllib2 import Request
from collections import Counter

Expand Down Expand Up @@ -158,6 +159,13 @@ def lambda_handler(event, context):
if d.lower() == nowDay:
isActiveDay = True

# Slice 24 hours
if re.match(r"^23[0-9]{2}$", nowMax) and \
re.match(r"^00[0-9]{2}$", now) and \
re.match(r"^00[0-9]{2}$", startTime):
startTime = "24" + startTime[2:]
now = "24" + now[2:]

# Append to start list
if startTime >= str(nowMax) and startTime <= str(now) and \
isActiveDay == True and state == "stopped":
Expand Down