mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 23:03:27 +01:00
Merge branch 'sources_tab'
# Conflicts: # AltStore.xcodeproj/project.pbxproj
This commit is contained in:
@@ -10,6 +10,13 @@ import Foundation
|
||||
|
||||
public extension Date
|
||||
{
|
||||
private static let mediumDateFormatter: DateFormatter = {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateStyle = .medium
|
||||
dateFormatter.timeStyle = .none
|
||||
return dateFormatter
|
||||
}()
|
||||
|
||||
func numberOfCalendarDays(since date: Date) -> Int
|
||||
{
|
||||
let today = Calendar.current.startOfDay(for: self)
|
||||
@@ -19,15 +26,15 @@ public extension Date
|
||||
return components.day!
|
||||
}
|
||||
|
||||
func relativeDateString(since date: Date, dateFormatter: DateFormatter) -> String
|
||||
func relativeDateString(since date: Date, dateFormatter: DateFormatter? = nil) -> String
|
||||
{
|
||||
let dateFormatter = dateFormatter ?? Date.mediumDateFormatter
|
||||
let numberOfDays = self.numberOfCalendarDays(since: date)
|
||||
|
||||
switch numberOfDays
|
||||
{
|
||||
case 0: return NSLocalizedString("Today", comment: "")
|
||||
case 1: return NSLocalizedString("Yesterday", comment: "")
|
||||
case 2...7: return String(format: NSLocalizedString("%@ days ago", comment: ""), NSNumber(value: numberOfDays))
|
||||
default: return dateFormatter.string(from: date)
|
||||
}
|
||||
}
|
||||
|
||||
16
AltStoreCore/Extensions/ProcessInfo+Previews.swift
Normal file
16
AltStoreCore/Extensions/ProcessInfo+Previews.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// ProcessInfo+Previews.swift
|
||||
// AltStoreCore
|
||||
//
|
||||
// Created by Riley Testut on 10/11/23.
|
||||
// Copyright © 2023 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension ProcessInfo
|
||||
{
|
||||
var isPreview: Bool {
|
||||
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user