mirror of
https://github.com/tonytins/amtkstat.git
synced 2026-10-24 05:32:54 -04:00
Cleaned up and removed columns so it is what an actual Solari board would show
- This update adds ISO date/time helpers for Amtrak timestamps, refactors the train table to show arrival time, status, and track details, and tracks the current station context in the UI. - It also hardens station status decoding with a safe fallback to Unknown and simplifies the row model to match the new display.
This commit is contained in:
parent
ebff2c9c32
commit
bf67475107
3 changed files with 99 additions and 31 deletions
37
Sources/AmtrakStatus/AmtrakDateFormatting.swift
Normal file
37
Sources/AmtrakStatus/AmtrakDateFormatting.swift
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import Foundation
|
||||
|
||||
struct AmtrakDateFormatting {
|
||||
static let isoFormatter = ISO8601DateFormatter()
|
||||
|
||||
static let timeFormatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .none
|
||||
formatter.timeStyle = .short
|
||||
return formatter
|
||||
}()
|
||||
|
||||
static let dateFormatter: DateFormatter = {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateStyle = .medium
|
||||
formatter.timeStyle = .none
|
||||
return formatter
|
||||
}()
|
||||
|
||||
static func time(from isoString: String?) -> String? {
|
||||
guard let isoString, !isoString.isEmpty, let date = isoFormatter.date(
|
||||
from: isoString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return timeFormatter.string(from: date)
|
||||
}
|
||||
|
||||
static func date(from isoString: String?) -> String? {
|
||||
guard let isoString, !isoString.isEmpty, let date = isoFormatter.date(
|
||||
from: isoString) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return dateFormatter.string(from: date)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue