-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display time in local timezone (e.g. New York timezone) #70
Comments
Hi @pranavladkat, hope this isn't too late. You should pass a let timeScaleOptions = TimeScaleOptions(
visible: true,
timeVisible: true,
ticksVisible: true,
tickMarkFormatter: .closure { parameters in
switch parameters.tickMarkType {
case .year:
parameters.time.date
.formatted(.dateTime.year(.relatedGregorian()))
case .month:
parameters.time.date
.formatted(.dateTime.month(.twoDigits).year(.twoDigits))
case .dayOfMonth:
parameters.time.date
.formatted(.dateTime.day(.twoDigits).month(.twoDigits))
case .time:
parameters.time.date
.formatted(
.verbatim(
"\(hour: .twoDigits(clock: .twentyFourHour, hourCycle: .zeroBased)):\(minute: .twoDigits)",
timeZone: .current,
calendar: .current
)
)
case .timeWithSeconds:
parameters.time.date
.formatted(
.verbatim(
"\(hour: .twoDigits(clock: .twentyFourHour, hourCycle: .zeroBased)):\(minute: .twoDigits):\(second: .twoDigits)",
timeZone: .current,
calendar: .current
)
)
}
}
) Note that if you want to have granular access to customize your output date, you may use Now, you make the chart like following: LightweightCharts(
options: ChartOptions(
// other parameters
timeScale: timeScaleOptions,
// ...
)
) Be aware that the fileprivate extension EventTime {
var date: Date {
switch self {
case let .utc(timestamp):
return Date(timeIntervalSince1970: timestamp)
case let .businessDay(businessDay):
let dateComponent = DateComponents(
timeZone: .gmt,
year: businessDay.year,
month: businessDay.month,
day: businessDay.day
)
return Calendar.current.date(from: dateComponent)!
case let .businessDayString(string):
let components = string.components(separatedBy: "-").compactMap { Int($0) }
let dateComponent = DateComponents(
timeZone: .gmt,
year: components[0],
month: components[1],
day: components[2]
)
return Calendar.current.date(from: dateComponent)!
}
}
} |
When using utc timestamp for denoting time in
CandlestickData
and/orHistogramData
, how can I display time in specific time zone (e.g. new york time zone or pacific time zone)? By default, it displays time zone in UTC.The text was updated successfully, but these errors were encountered: