Skip to content

Commit 94cce3c

Browse files
authored
Merge pull request #1176 from ahoppen/ahoppen/time-zone
Set time zone to the user's local time zone when using date formatters
2 parents 3dd5045 + 465ca45 commit 94cce3c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Sources/Diagnose/DiagnoseCommand.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public struct DiagnoseCommand: AsyncParsableCommand {
134134

135135
for crashInfo in crashInfos {
136136
let dateFormatter = DateFormatter()
137+
dateFormatter.timeZone = NSTimeZone.local
137138
dateFormatter.dateStyle = .none
138139
dateFormatter.timeStyle = .medium
139140
let progressMessagePrefix = "Reducing Swift compiler crash at \(dateFormatter.string(from: crashInfo.date))"
@@ -304,7 +305,9 @@ public struct DiagnoseCommand: AsyncParsableCommand {
304305

305306
progressBar = PercentProgressAnimation(stream: stderrStream, header: "Diagnosing sourcekit-lsp issues")
306307

307-
let date = ISO8601DateFormatter().string(from: Date()).replacingOccurrences(of: ":", with: "-")
308+
let dateFormatter = ISO8601DateFormatter()
309+
dateFormatter.timeZone = NSTimeZone.local
310+
let date = dateFormatter.string(from: Date()).replacingOccurrences(of: ":", with: "-")
308311
let bundlePath = FileManager.default.temporaryDirectory
309312
.appendingPathComponent("sourcekitd-reproducer-\(date)")
310313
try FileManager.default.createDirectory(at: bundlePath, withIntermediateDirectories: true)
@@ -330,9 +333,9 @@ public struct DiagnoseCommand: AsyncParsableCommand {
330333
print(
331334
"""
332335
333-
Bundle created.
334-
When filing an issue at https://github.com/apple/sourcekit-lsp/issues/new,
335-
please attach the bundle located at
336+
Bundle created.
337+
When filing an issue at https://github.com/apple/sourcekit-lsp/issues/new,
338+
please attach the bundle located at
336339
\(bundlePath.path)
337340
"""
338341
)

Sources/Diagnose/SwiftFrontendCrashScraper.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct SwiftFrontendCrashScraper {
7070
}
7171
let interestingString = fileContents[firstNewline...]
7272
let dateFormatter = DateFormatter()
73+
dateFormatter.timeZone = NSTimeZone.local
7374
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSS Z"
7475
let decoder = JSONDecoder()
7576
decoder.dateDecodingStrategy = .formatted(dateFormatter)

Sources/LSPLogging/NonDarwinLogging.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ public struct NonDarwinLogMessage: ExpressibleByStringInterpolation, Expressible
245245
/// a new `DateFormatter` is rather expensive and its the same for all loggers.
246246
private let dateFormatter = {
247247
let dateFormatter = DateFormatter()
248-
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
248+
dateFormatter.timeZone = NSTimeZone.local
249+
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSS Z"
249250
return dateFormatter
250251
}()
251252

0 commit comments

Comments
 (0)