Skip to content

Commit

Permalink
Merge pull request #1 from dasdom/main
Browse files Browse the repository at this point in the history
Also fail on weekends
  • Loading branch information
icanzilb authored Jun 16, 2022
2 parents 7538683 + 6a7073e commit 1789ea6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions PluginBinary/PluginBinary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ extension String: Error { }
@main class PluginBinary {
static func main() throws {
let outputURL = URL(fileURLWithPath: ProcessInfo.processInfo.arguments[1])

let content = content(for: Date())

try content.write(to: outputURL, atomically: true, encoding: .utf8)
}

static func content(for date: Date) -> String {
let content: String

if (9.0...18.0 ~= Date().time) { // Your 9-6 basically
if (false == Calendar.current.isDateInWeekend(date) && // Exclude weekend
9.0...18.0 ~= date.time) { // Your 9-6 basically
// Working hours
content = "// All is good, do not disturb is off."
} else {
// DND
content = #"#error("Do not disturb is ON")"#
}

try content.write(to: outputURL, atomically: true, encoding: .utf8)
return content
}
}

Expand Down

0 comments on commit 1789ea6

Please sign in to comment.