-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add timezone to dateformatter (#500)
- Loading branch information
Showing
10 changed files
with
266 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
CriticalMapsKit/.swiftpm/xcode/xcshareddata/xcschemes/NextRideFeatureTests.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1510" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<TestPlans> | ||
<TestPlanReference | ||
reference = "container:../Testplans/NextRideFeatureTests.xctestplan" | ||
default = "YES"> | ||
</TestPlanReference> | ||
</TestPlans> | ||
<Testables> | ||
<TestableReference | ||
skipped = "NO"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "NextRideFeatureTests" | ||
BuildableName = "NextRideFeatureTests" | ||
BlueprintName = "NextRideFeatureTests" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</TestableReference> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
|
||
public extension TimeZone { | ||
// Europe | ||
static let germany = TimeZone(identifier: "Europe/Berlin")! | ||
static let gmt = TimeZone(identifier: "GMT")! | ||
static let spain = TimeZone(identifier: "Europe/Madrid")! | ||
static let france = TimeZone(identifier: "Europe/Paris")! | ||
static let greece = TimeZone(identifier: "Europe/Athens")! | ||
|
||
// America | ||
static let ecuador = TimeZone(identifier: "America/Guayaquil")! | ||
static let cuba = TimeZone(identifier: "America/Havana")! | ||
|
||
// Africa | ||
static let egypt = TimeZone(identifier: "Africa/Cairo")! | ||
static let southAfrica = TimeZone(identifier: "Africa/Johannesburg")! | ||
|
||
// Asia | ||
static let india = TimeZone(identifier: "Asia/Kolkata")! | ||
static let japan = TimeZone(identifier: "Asia/Tokyo")! | ||
|
||
// USA | ||
static let newYork = TimeZone(identifier: "America/New_York")! | ||
static let losAngeles = TimeZone(identifier: "America/Los_Angeles")! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
CriticalMapsKit/Tests/NextRideFeatureTests/RideTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import ComposableArchitecture | ||
import Helpers | ||
import SharedModels | ||
import XCTest | ||
|
||
final class RideTests: XCTestCase { | ||
func test_rideInGMTTimezone() { | ||
// arrange | ||
let ride = Ride.mock() | ||
|
||
// act | ||
withDependencies { | ||
$0.timeZone = .gmt | ||
} operation: { | ||
XCTAssertEqual( | ||
"20:00", | ||
ride.dateTime.humanReadableTime | ||
) | ||
} | ||
} | ||
|
||
func test_rideInGermanTimezone() { | ||
// arrange | ||
let ride = Ride.mock() | ||
|
||
// act | ||
withDependencies { | ||
$0.timeZone = .germany | ||
} operation: { | ||
XCTAssertEqual( | ||
"20:00", | ||
ride.dateTime.humanReadableTime | ||
) | ||
} | ||
} | ||
|
||
func test_rideInGreeceTimezone() { | ||
// arrange | ||
let ride = Ride.mock() | ||
|
||
// act | ||
withDependencies { | ||
$0.timeZone = .greece | ||
$0.calendar = .init(identifier: .gregorian) | ||
} operation: { | ||
XCTAssertEqual( | ||
"20:00", | ||
ride.dateTime.humanReadableTime | ||
) | ||
} | ||
} | ||
|
||
func test_rideInEcuadorTimezone() { | ||
// arrange | ||
let ride = Ride.mock() | ||
|
||
// act | ||
withDependencies { | ||
$0.timeZone = .ecuador | ||
$0.calendar = .init(identifier: .gregorian) | ||
} operation: { | ||
XCTAssertEqual( | ||
"20:00", | ||
ride.dateTime.humanReadableTime | ||
) | ||
} | ||
} | ||
} | ||
|
||
extension Ride { | ||
static func mock() -> Self { | ||
Self( | ||
id: 0, | ||
slug: nil, | ||
title: "CriticalMaps Berlin", | ||
description: nil, | ||
dateTime: Date(timeIntervalSince1970: 1711738800), | ||
location: nil, | ||
latitude: 53.1235, | ||
longitude: 13.4234, | ||
estimatedParticipants: nil, | ||
estimatedDistance: nil, | ||
estimatedDuration: nil, | ||
enabled: true, | ||
disabledReason: nil, | ||
disabledReasonMessage: nil, | ||
rideType: .criticalMass | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<gpx version="1.1" creator="Xcode"> | ||
<wpt lat="38.7223" lon="-9.1393"> | ||
<name>Cupertino</name> | ||
<time>2014-09-24T14:55:37Z</time> | ||
</wpt> | ||
|
||
</gpx> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"configurations" : [ | ||
{ | ||
"id" : "EC875105-37D8-413B-989B-09862018C3C9", | ||
"name" : "Test Scheme Action", | ||
"options" : { | ||
"language" : "en", | ||
"region" : "GB" | ||
} | ||
}, | ||
{ | ||
"id" : "1858BF7A-D057-468A-B31F-AD3EB6637E6E", | ||
"name" : "Configuration 2", | ||
"options" : { | ||
"environmentVariableEntries" : [ | ||
{ | ||
"key" : "setenv(\"TZ\", identifier, 1)", | ||
"value" : "" | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"defaultOptions" : { | ||
"language" : "en", | ||
"locationScenario" : { | ||
"identifier" : "London, England", | ||
"referenceType" : "built-in" | ||
}, | ||
"region" : "GB" | ||
}, | ||
"testTargets" : [ | ||
{ | ||
"target" : { | ||
"containerPath" : "container:", | ||
"identifier" : "NextRideFeatureTests", | ||
"name" : "NextRideFeatureTests" | ||
} | ||
} | ||
], | ||
"version" : 1 | ||
} |
Oops, something went wrong.