On Fri, 17 Sep 2010 22:27:50 -0700, Igal Koshevoy wrote:
> Date: Fri, 17 Sep 2010 22:27:50 -0700
> From: Igal Koshevoy <[email protected]>
> To: [email protected]
> Subject: [Puppet-dev] [PATCH/puppet-dashboard 1/1] [#4794] Fix timezone
>  shown
>  in views.
> X-Mailer: git-send-email 1.7.2.3
> Message-Id: <[email protected]>
> 
> This patch fixes a number of problems related to timezones:
> 
> 1. ReportsController#show displayed log entries with values in the local
> timezone of the Puppet client, not the Puppet Dashboard server.
> 2. Default date/time formats don't define their default timezone.
> 3. Code had many unnecessary #to_s calls.
> 4. Code had formatting in #to_s rather than using the defaults.
> 
> Signed-off-by: Igal Koshevoy <[email protected]>
> ---
>  app/views/nodes/_nodes.html.haml                  |    2 +-
>  app/views/nodes/show.html.haml                    |    2 +-
>  app/views/puppet/transaction/reports/_report.haml |    2 +-
>  app/views/puppet/util/logs/_log.haml              |    2 +-
>  app/views/reports/_report.html.haml               |    2 +-
>  app/views/reports/index.html.haml                 |    2 +-
>  app/views/statuses/_run_failure.html.haml         |    2 +-
>  app/views/statuses/_run_time.html.haml            |    2 +-
>  config/initializers/time_formats.rb               |    6 ++++--
>  9 files changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/app/views/nodes/_nodes.html.haml 
> b/app/views/nodes/_nodes.html.haml
> index 13d07be..3d8b8b2 100644
> --- a/app/views/nodes/_nodes.html.haml
> +++ b/app/views/nodes/_nodes.html.haml
> @@ -23,7 +23,7 @@
>            %td.hostname
>              = link_to h(node.name), node
>            %td.latest_report
> -            = node.last_report ? node.last_report.time.to_s : "Has not 
> reported"
> +            = node.last_report ? node.last_report.time : "Has not reported"
>        = pagination_for nodes, more_link
>      - else
>        %td.empty{:colspan => 3}
> diff --git a/app/views/nodes/show.html.haml b/app/views/nodes/show.html.haml
> index bca6536..f630c70 100644
> --- a/app/views/nodes/show.html.haml
> +++ b/app/views/nodes/show.html.haml
> @@ -67,7 +67,7 @@
>              - @node.reports.limit(reports_limit).each do |report|
>                %tr
>                  = report_status_td(report)
> -                %td= link_to report.time.to_s, report
> +                %td= link_to report.time, report
>                  %td= report.total_resources
>                  %td= report.failed_resources
>                  %td= report.total_time
> diff --git a/app/views/puppet/transaction/reports/_report.haml 
> b/app/views/puppet/transaction/reports/_report.haml
> index c380689..dd27166 100644
> --- a/app/views/puppet/transaction/reports/_report.haml
> +++ b/app/views/puppet/transaction/reports/_report.haml
> @@ -1,6 +1,6 @@
>  -# FIXME Is anything using this partial?
>  .report.grouping
> -  %h2= report.time.to_s
> +  %h2= report.time
>  
>    .section
>      %h3 Metrics
> diff --git a/app/views/puppet/util/logs/_log.haml 
> b/app/views/puppet/util/logs/_log.haml
> index efd66a9..da7ca19 100644
> --- a/app/views/puppet/util/logs/_log.haml
> +++ b/app/views/puppet/util/logs/_log.haml
> @@ -6,4 +6,4 @@
>    %td
>      %code= h log.source
>    %td.nowrap
> -    %code= log.time.to_s
> +    %code= log.time
> diff --git a/app/views/reports/_report.html.haml 
> b/app/views/reports/_report.html.haml
> index 5a23af7..4cf28bc 100644
> --- a/app/views/reports/_report.html.haml
> +++ b/app/views/reports/_report.html.haml
> @@ -3,7 +3,7 @@
>      %span.status{:class => report.status}
>        = report_status_icon(report)
>        Report:
> -      = report.time.to_s
> +      = report.time
>      - if report.node
>        %span.alt for
>        = link_to report.node.name, report.node
> diff --git a/app/views/reports/index.html.haml 
> b/app/views/reports/index.html.haml
> index 8b5e2a8..ce2390a 100644
> --- a/app/views/reports/index.html.haml
> +++ b/app/views/reports/index.html.haml
> @@ -27,7 +27,7 @@
>            - for report in @reports
>              %tr.nowrap[report]
>                = report_status_td(report)
> -              %td= link_to report.time.to_s, report
> +              %td= link_to report.time, report
>                - unless @node
>                  %td= link_to_if report.node, h(report.host), 
> node_path(report.node)
>                %td= report.total_resources
> diff --git a/app/views/statuses/_run_failure.html.haml 
> b/app/views/statuses/_run_failure.html.haml
> index 32df9b0..4c2f93a 100644
> --- a/app/views/statuses/_run_failure.html.haml
> +++ b/app/views/statuses/_run_failure.html.haml
> @@ -13,7 +13,7 @@
>      %thead
>        %tr.labels
>          - statuses.each do |status|
> -          %th= status.start.strftime("%m/%d/%y")
> +          %th= status.start.to_s(:date)
>      %tbody
>        %tr.succeeded
>          - statuses.each do |status|
> diff --git a/app/views/statuses/_run_time.html.haml 
> b/app/views/statuses/_run_time.html.haml
> index 053caa1..3c56216 100644
> --- a/app/views/statuses/_run_time.html.haml
> +++ b/app/views/statuses/_run_time.html.haml
> @@ -5,7 +5,7 @@
>      %thead
>        %tr.labels
>          - reports.map{|r| r.time}.each do |time|
> -          %th= time.strftime('%I:%M%p')
> +          %th= time.to_s(:time)
>      %tbody
>        %tr.runtimes
>          - reports.map{|r| r.total_time}.compact.each do |time|
> diff --git a/config/initializers/time_formats.rb 
> b/config/initializers/time_formats.rb
> index 5e6353a..61f48eb 100644
> --- a/config/initializers/time_formats.rb
> +++ b/config/initializers/time_formats.rb
> @@ -1,6 +1,8 @@
>  # TODO make format customizable through an external configuration file.
>  Time::DATE_FORMATS.update(
>    # :default => lambda{|time| time.strftime('%m/%d/%y ') + 
> time.strftime('%I:%M%p').downcase }
> -  :default => lambda{|time| time.strftime('%Y-%m-%d %H:%M %Z') },
> -  :date => lambda{|time| time.strftime('%Y-%m-%d') }
> +  :default => lambda{|time| time.in_time_zone.strftime('%Y-%m-%d %H:%M %Z') 
> },
> +  :date => lambda{|time| time.in_time_zone.strftime('%Y-%m-%d') },
> +  :time => lambda{|time| time.in_time_zone.strftime('%I:%M%p') }
>  )
> +
> -- 
> 1.7.2.3
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.
> 

Just so it's been recorded here, too: +1

-- 
Jacob Helwig

Attachment: signature.asc
Description: Digital signature

Reply via email to