Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Make it build
Browse files Browse the repository at this point in the history
  • Loading branch information
steffendsommer committed May 19, 2017
1 parent 7333eb5 commit 4da5016
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Sources/Date+Sugar.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import Vapor

extension Date {
// MARK: Errors
Expand Down Expand Up @@ -48,9 +49,9 @@ extension Date {
/// Take you to monday 00:00:00 current week
///
/// - Returns: Date
public func startOfWeek(calendar: Calendar = Calendar()) -> Date {
public func startOfWeek(calendar: Calendar = Calendar(identifier: .gregorian)) -> Date {
var components = calendar.dateComponents([.weekOfYear, .yearForWeekOfYear], from: self.startOfDay())
components.weekday = .monday.rawValue
components.weekday = Weekday.monday.rawValue
let startOfWeek = calendar.date(from: components)!
return startOfWeek
}
Expand All @@ -60,9 +61,9 @@ extension Date {
/// Take you to sunday 23:59:59 current week
///
/// - Returns: Date
public func endOfWeek(calendar: Calendar = Calendar()) -> Date {
public func endOfWeek(calendar: Calendar = Calendar(identifier: .gregorian)) -> Date {
var components = calendar.dateComponents([.weekOfYear, .yearForWeekOfYear], from: self.endOfDay())
components.weekday = .sunday.rawValue
components.weekday = Weekday.sunday.rawValue
let startOfWeek = calendar.date(from: components)!
return startOfWeek.endOfDay()
}
Expand Down Expand Up @@ -172,7 +173,7 @@ extension Date {
/// Start of day
///
/// - Returns: Date
public func startOfDay(calendar: Calendar = Calendar()) -> Date {
public func startOfDay(calendar: Calendar = Calendar(identifier: .gregorian)) -> Date {
let unitFlags = Set<Calendar.Component>([.year, .month, .day])
let components = calendar.dateComponents(unitFlags, from: self)
return calendar.date(from: components)!
Expand All @@ -181,7 +182,7 @@ extension Date {
/// End of day
///
/// - Returns: Date
public func endOfDay(calendar: Calendar = Calendar()) -> Date {
public func endOfDay(calendar: Calendar = Calendar(identifier: .gregorian)) -> Date {
var components = DateComponents()
components.day = 1
let date = calendar.date(byAdding: components, to: self.startOfDay())
Expand All @@ -192,7 +193,7 @@ extension Date {
/// Start of month
///
/// - Returns: Date
public func startOfMonth(calendar: Calendar = Calendar()) -> Date {
public func startOfMonth(calendar: Calendar = Calendar(identifier: .gregorian)) -> Date {
let unitFlags = Set<Calendar.Component>([.year, .month])
let components = calendar.dateComponents(unitFlags, from: self)
return calendar.date(from: components)!
Expand Down

0 comments on commit 4da5016

Please sign in to comment.