Skip to content

Commit ae21c8f

Browse files
committed
Move localized time to its own field
1 parent 6d1faff commit ae21c8f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CoreLocationCLI/main.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Delegate: NSObject, CLLocationManagerDelegate {
7272
"speed": "\(Int(location.speed))",
7373
"h_accuracy": "\(Int(location.horizontalAccuracy))",
7474
"v_accuracy": "\(Int(location.verticalAccuracy))",
75-
"time": locatedTime ?? location.timestamp.description,
75+
"time": location.timestamp.description,
7676

7777
// Placemark
7878
"name": placemark?.name,
@@ -87,6 +87,7 @@ class Delegate: NSObject, CLLocationManagerDelegate {
8787
"subThoroughfare": placemark?.subThoroughfare,
8888
"region": placemark?.region?.identifier,
8989
"timeZone": placemark?.timeZone?.identifier,
90+
"time_local": locatedTime,
9091

9192
// Address
9293
"address": formattedPostalAddress
@@ -101,7 +102,7 @@ class Delegate: NSObject, CLLocationManagerDelegate {
101102
output = output.replacingOccurrences(of: "%speed", with: "\(Int(location.speed))")
102103
output = output.replacingOccurrences(of: "%h_accuracy", with: "\(Int(location.horizontalAccuracy))")
103104
output = output.replacingOccurrences(of: "%v_accuracy", with: "\(Int(location.verticalAccuracy))")
104-
output = output.replacingOccurrences(of: "%time", with: locatedTime ?? location.timestamp.description)
105+
output = output.replacingOccurrences(of: "%time", with: location.timestamp.description)
105106

106107
// Placemark
107108
output = output.replacingOccurrences(of: "%name", with: String(placemark?.name ?? ""))
@@ -116,6 +117,7 @@ class Delegate: NSObject, CLLocationManagerDelegate {
116117
output = output.replacingOccurrences(of: "%subThoroughfare", with: String(placemark?.subThoroughfare ?? ""))
117118
output = output.replacingOccurrences(of: "%region", with: String(placemark?.region?.identifier ?? ""))
118119
output = output.replacingOccurrences(of: "%timeZone", with: String(placemark?.timeZone?.identifier ?? ""))
120+
output = output.replacingOccurrences(of: "%time_local", with: String(locatedTime ?? ""))
119121

120122
// Address
121123
output = output.replacingOccurrences(of: "%address", with: formattedPostalAddress)
@@ -210,6 +212,7 @@ class Delegate: NSObject, CLLocationManagerDelegate {
210212
%subThoroughfare Additional street-level information
211213
%region Reverse geocoded geographic region
212214
%timeZone Reverse geocoded time zone
215+
%time_local Localized time using reverse geocoded time zone
213216
-json Prints a JSON object with all information available
214217
215218
Default format if not specified is: %latitude %longitude.
@@ -232,7 +235,7 @@ for (i, argument) in ProcessInfo().arguments.enumerated() {
232235
case "-format":
233236
if ProcessInfo().arguments.count > i+1 {
234237
delegate.format = .string(ProcessInfo().arguments[i+1])
235-
let placemarkStrings = ["%address", "%name", "%isoCountryCode", "%country", "%postalCode", "%administrativeArea", "%subAdministrativeArea", "%locality", "%subLocality", "%thoroughfare", "%subThoroughfare", "%region", "%timeZone"]
238+
let placemarkStrings = ["%address", "%name", "%isoCountryCode", "%country", "%postalCode", "%administrativeArea", "%subAdministrativeArea", "%locality", "%subLocality", "%thoroughfare", "%subThoroughfare", "%region", "%timeZone", "%time_local"]
236239
if placemarkStrings.contains(where:ProcessInfo().arguments[i+1].contains) {
237240
delegate.requiresPlacemarkLookup = true
238241
}

0 commit comments

Comments
 (0)