Created
January 8, 2018 03:57
-
-
Save shotarok/20ed0cdc4074332bb72747fc9ad81f2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LavaYoga() { | |
var criteria = "from:[email protected] 予約完了"; | |
eachUnreadMessage(criteria, function (message) { | |
var subject = message.getSubject(); | |
Logger.log(subject); | |
var [matched, place] = /【LAVA】([^\n]+店)予約完了/.exec(subject); | |
var body = message.getBody(); | |
Logger.log(body); | |
var [matched, month, day, sh, sm, eh, em, kind] = /(\d*)月(\d*)日\([月火水木金土日]\) (\d\d):(\d\d)~(\d\d):(\d\d)[^\n]*\n([^\n]+)/.exec(body); | |
Logger.log(matched); | |
var year = estimateYear(month, day, sh, sm) | |
Logger.log(year) | |
createEvent("LAVA Yoga [" + kind + "]@" + place, | |
new Date(year, month-1, day, sh, sm), | |
new Date(year, month-1, day, eh, em)); | |
} | |
); | |
} | |
function estimateYear(month, day, sh, sm) { | |
var current = new Date; | |
var thisYear = new Date(current.getFullYear(), month-1, day, sh, sm); | |
var nextYear = new Date(current.getFullYear()+1, month-1, day, sh, sm); | |
var d = (current <= thisYear) ? thisYear : nextYear; | |
return d.getFullYear() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment