i am trying to build a running Docker Image for my Kitura AppServer. I am doing the Coding in XCode on my MacBookbut i want to deploy the server to a Cloud Environment by using Docker.
This requires to make a build in Unix in my case an ibm Version of Ubuntu ...
FROM ibmcom/swift-ubuntu:5.0.2
Unfortunately the build process following the descriptions is quite frustrating and it takes some times multiple approaches to have a running image using the build commands listed here: https://www.kitura.io/docs/deploying/docker.html
But every once in a while i have a working package. However after many trial and error i have learned that the Docker Image running on Ubuntu does not like my Calendar calls to get the day of the week.
var todayWeekday = Calendar.current.dateComponents(in: timeZone!, from: date).weekday! - 1
This causes my container to stop with an exception and requires a restart...
Doe any one have an alternative solution to call reliable the day of the week with a function that can work with MacOS as well as Ubuntu ?
I dont want to write my own method as i fear i miss some factors that are coming with the complexity of dates.
Seems there was a simple approach on that issue... I could use the DateFormatter()
let timeFormatWd = DateFormatter()
timeFormatWd.dateFormat = "e"
//New version of getting today Weekday !
let todayWeekday = Int(timeFormatWd.string(from: date))