mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
Fixes #2338, [SDKONCALL-237], [SDK-2974]. `Int` is actually 32 bits in 32-bit platforms, like `watchOS` still is (sort of). This fixes 2 potential `Int` overflows: `Date.millisecondsSince1970` and `DispatchTimeInterval` arithmetic using `nanoseconds`. See also #2340. [SDKONCALL-237]: https://revenuecats.atlassian.net/browse/SDKONCALL-237?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
29 lines
702 B
Swift
29 lines
702 B
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// Date+Extensions.swift
|
|
//
|
|
// Created by Josh Holtz on 6/28/21.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension Date {
|
|
|
|
init(millisecondsSince1970: UInt64) {
|
|
self.init(timeIntervalSince1970: TimeInterval(millisecondsSince1970) / 1000)
|
|
}
|
|
|
|
/// - Important: this needs to be 64 bits because `Int` is 32 bits in watchOS
|
|
var millisecondsSince1970: UInt64 {
|
|
return UInt64(self.timeIntervalSince1970 * 1000)
|
|
}
|
|
|
|
}
|