/*
Welcome to the machine
Welcome my son, welcome to the machine.
Where have you been?
It's alright we know where you've been.
You've been in the pipeline, filling in time,
Provided with toys and 'Scouting for Boys'.
You brought a guitar to punish your ma,
And you didn't like school, and you
Know you're nobody's fool,
So welcome to the machine.
Welcome my son, welcome to the machine.
What did you dream?
It's alright we told you what to dream.
You dreamed of a big star,
He played a mean guitar,
He always ate in the Steak Bar.
He loved to drive in his Jaguar.
So welcome to the Machine.
*/
import Cocoa
// First cut, November 17th 2016
// Should be upgraded to functional programming
// These funcions are useful when working with days and monthSymbols
//
public func numberOfDaysInMonthsFor(year : Int) -> [Int:Int] {
var result = [Int:Int]()
var dc = DateComponents()
dc.year = year
let calendar = Calendar.current
for monthNumber in 1...12 {
dc.month = monthNumber
let date = calendar.date(from: dc)!
let range = calendar.range(of: .day, in: .month, for: date)!
let numDays = range.count
result.updateValue(numDays, forKey: monthNumber)
}
return result
} // End of numberOfDaysInMonthsFor(year:)
//
// Names of days and months are also easy to find out through These
// functions.
//
// localeIdentifier for Spain is "es_ES"
// localeIdentifier for USA is "en_US"
// localeIdentifier for Germany is "de_DE"
// and so on
//
public func namesOfDaysFor(localeIdentifier : String) -> [String] {
let df = DateFormatter()
df.locale = Locale(identifier: localeIdentifier)
return df.weekdaySymbols
}
public func namesOfMonthsFor(localeIdentifier : String) -> [String] {
let df = DateFormatter()
df.locale = Locale(identifier: localeIdentifier)
return df.monthSymbols
}