mirror of
https://github.com/tonytins/amtkstat.git
synced 2026-10-24 05:32:54 -04:00
Time column accounts for destination's time zone
This commit is contained in:
parent
e1c39aa457
commit
bf420b7480
3 changed files with 81 additions and 33 deletions
|
|
@ -26,13 +26,26 @@ struct AmtrakDateFormatting {
|
|||
return isoFormatter.date(from: isoString)
|
||||
}
|
||||
|
||||
func time(from isoString: String?, timeZone: TimeZone? = nil) -> String? {
|
||||
func time(from isoString: String?, timeZone: TimeZone?, relativeTo otherZone: TimeZone? = nil) -> String? {
|
||||
guard let isoString, !isoString.isEmpty, let date = isoFormatter.date(
|
||||
from: isoString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
timeFormatter.timeZone = timeZone
|
||||
return timeFormatter.string(from: date)
|
||||
|
||||
let formatted = timeFormatter.string(from: date)
|
||||
|
||||
guard
|
||||
let timeZone,
|
||||
let otherZone,
|
||||
timeZone.identifier != otherZone.identifier,
|
||||
let abbreviation = timeZone.abbreviation(for: date)
|
||||
else {
|
||||
return formatted
|
||||
}
|
||||
|
||||
return "\(formatted) \(abbreviation)"
|
||||
}
|
||||
|
||||
func localTime(timeZone: TimeZone?) -> String {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue