DateManager.swift
1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// DateManager.swift
// browser
//
// Created by Artem Talko on 17.10.2023.
//
import Foundation
import UIKit
final class DateManager {
static let shared = DateManager()
let currentDate = Date()
let currentTimestamp = Date().timeIntervalSince1970
var dateFormatter: DateFormatter{
let obj = DateFormatter()
obj.dateFormat = "EEEE, d MMM"
return obj
}
private init() {}
func getTimeFromDB(_ date: Date?) -> String {
let timeFormatter = DateFormatter()
timeFormatter.dateFormat = "h:mm a"
return timeFormatter.string(from: date ?? Date())
}
func getSubscriptionExpirationDate() {
guard CachingManager.shared.expirationDate != nil else {
Task {
if let activeSubscription = SubscriptionManager.shared.purchasedSubscriptions.first {
switch await activeSubscription.latestTransaction {
case .verified(let transaction):
CachingManager.shared.expirationDate = transaction.expirationDate?.timeIntervalSince1970
default:
return
}
}
}
return
}
}
}