force calendar to use UTC
This commit is contained in:
@@ -126,6 +126,7 @@ struct StatsController: RouteCollection {
|
|||||||
private func getStartOfMonth(month:Int, year:Int) -> Date {
|
private func getStartOfMonth(month:Int, year:Int) -> Date {
|
||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
var components = DateComponents()
|
var components = DateComponents()
|
||||||
|
components.timeZone = TimeZone(identifier: "GMT")
|
||||||
components.day = 1
|
components.day = 1
|
||||||
components.month = month
|
components.month = month
|
||||||
components.year = year
|
components.year = year
|
||||||
@@ -138,6 +139,7 @@ struct StatsController: RouteCollection {
|
|||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
var components = DateComponents()
|
var components = DateComponents()
|
||||||
components.day = -1
|
components.day = -1
|
||||||
|
components.timeZone = TimeZone(identifier: "GMT")
|
||||||
components.month = month + 1
|
components.month = month + 1
|
||||||
components.year = year
|
components.year = year
|
||||||
components.hour = 23
|
components.hour = 23
|
||||||
@@ -149,6 +151,8 @@ struct StatsController: RouteCollection {
|
|||||||
private func getStartOfDay(day:Int, month:Int, year:Int) -> Date {
|
private func getStartOfDay(day:Int, month:Int, year:Int) -> Date {
|
||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
var components = DateComponents()
|
var components = DateComponents()
|
||||||
|
components.timeZone = TimeZone(identifier: "GMT")
|
||||||
|
|
||||||
components.day = day
|
components.day = day
|
||||||
components.month = month
|
components.month = month
|
||||||
components.year = year
|
components.year = year
|
||||||
@@ -160,6 +164,7 @@ struct StatsController: RouteCollection {
|
|||||||
private func getEndOfDay(day:Int, month:Int, year:Int) -> Date {
|
private func getEndOfDay(day:Int, month:Int, year:Int) -> Date {
|
||||||
let calendar = Calendar.current
|
let calendar = Calendar.current
|
||||||
var components = DateComponents()
|
var components = DateComponents()
|
||||||
|
components.timeZone = TimeZone(identifier: "GMT")
|
||||||
components.day = day
|
components.day = day
|
||||||
components.month = month
|
components.month = month
|
||||||
components.year = year
|
components.year = year
|
||||||
@@ -168,6 +173,31 @@ struct StatsController: RouteCollection {
|
|||||||
return calendar.date(from: components)!
|
return calendar.date(from: components)!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func getStartDate() -> Date {
|
||||||
|
|
||||||
|
let calendar = Calendar.current
|
||||||
|
var components = DateComponents()
|
||||||
|
components.timeZone = TimeZone(identifier: "GMT")
|
||||||
|
components.day = 20
|
||||||
|
components.month = 03
|
||||||
|
components.year = 2020
|
||||||
|
components.hour = 0
|
||||||
|
components.minute = 0
|
||||||
|
return calendar.date(from: components)!
|
||||||
|
}
|
||||||
|
|
||||||
|
private func createDate(day:Int, month:Int, year:Int) -> Date {
|
||||||
|
let calendar = Calendar.current
|
||||||
|
|
||||||
|
var components = DateComponents()
|
||||||
|
components.timeZone = TimeZone(identifier: "GMT")
|
||||||
|
components.day = day
|
||||||
|
components.month = month
|
||||||
|
components.year = year
|
||||||
|
return calendar.date(from: components)!
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -357,37 +387,6 @@ struct StatsController: RouteCollection {
|
|||||||
return getRatios(Array(previousDays)[0..<previousDays.count], allDailyStats: &stats, cumulativeWinLossRatios: &cumulativeWinLossRatios, eventLoop: req.eventLoop)
|
return getRatios(Array(previousDays)[0..<previousDays.count], allDailyStats: &stats, cumulativeWinLossRatios: &cumulativeWinLossRatios, eventLoop: req.eventLoop)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private func getStartDate() -> Date {
|
|
||||||
|
|
||||||
let calendar = Calendar.current
|
|
||||||
|
|
||||||
var components = DateComponents()
|
|
||||||
components.timeZone = TimeZone(identifier: "America/New_York")!
|
|
||||||
components.day = 20
|
|
||||||
components.month = 03
|
|
||||||
components.year = 2020
|
|
||||||
components.hour = 0
|
|
||||||
components.minute = 0
|
|
||||||
|
|
||||||
return calendar.date(from: components)!
|
|
||||||
}
|
|
||||||
|
|
||||||
private func createDate(day:Int, month:Int, year:Int) -> Date {
|
|
||||||
let calendar = Calendar.current
|
|
||||||
|
|
||||||
|
|
||||||
var components = DateComponents()
|
|
||||||
components.day = day
|
|
||||||
components.month = month
|
|
||||||
components.year = year
|
|
||||||
|
|
||||||
|
|
||||||
return calendar.date(from: components)!
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user