Merge branch 'sources_tab'

# Conflicts:
#	AltStore.xcodeproj/project.pbxproj
This commit is contained in:
Riley Testut
2023-10-19 14:18:43 -05:00
39 changed files with 1978 additions and 795 deletions

View File

@@ -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)
}
}

View 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"
}
}