Class: Pvectl::Presenters::TimeConfig
- Defined in:
- lib/pvectl/presenters/time_config.rb
Overview
Presenter for node time and timezone settings.
Renders both the UTC timestamp and the node’s local wall clock as human-readable strings. Proxmox returns ‘localtime` as seconds-since-epoch interpreted as if the node’s wall clock were UTC, so we format it via ‘Time.at(localtime).utc.strftime(…)` to preserve the node’s view.
Constant Summary collapse
- TIMESTAMP_FORMAT =
Date format for timestamp columns.
"%Y-%m-%d %H:%M:%S"
Instance Method Summary collapse
-
#columns ⇒ Array<String>
Returns column headers for table output.
-
#to_hash(model) ⇒ Hash{String => Object}
Converts TimeConfig model to a hash for JSON/YAML output.
-
#to_row(model, **_context) ⇒ Array<String>
Converts TimeConfig model to a table row.
Methods inherited from Base
#extra_columns, #extra_values, #tags_array, #tags_display, #template_display, #to_description, #to_wide_row, #uptime_human, #wide_columns
Instance Method Details
#columns ⇒ Array<String>
Returns column headers for table output.
26 27 28 |
# File 'lib/pvectl/presenters/time_config.rb', line 26 def columns ["NODE", "TIMEZONE", "TIME (UTC)", "LOCAL TIME"] end |
#to_hash(model) ⇒ Hash{String => Object}
Converts TimeConfig model to a hash for JSON/YAML output.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/pvectl/presenters/time_config.rb', line 48 def to_hash(model) { "node" => model.node_name, "timezone" => model.timezone, "time" => model.time, "localtime" => model.localtime, "time_iso" => iso(model.time), "localtime_iso" => iso(model.localtime) } end |
#to_row(model, **_context) ⇒ Array<String>
Converts TimeConfig model to a table row.
35 36 37 38 39 40 41 42 |
# File 'lib/pvectl/presenters/time_config.rb', line 35 def to_row(model, **_context) [ model.node_name || "-", model.timezone || "-", (model.time), (model.localtime) ] end |