Commit fa36749b authored by Robert Speicher's avatar Robert Speicher

Add two custom Date/Time conversion formats

parent 59305715
...@@ -206,7 +206,7 @@ module ApplicationHelper ...@@ -206,7 +206,7 @@ module ApplicationHelper
element = content_tag :time, time.to_s, element = content_tag :time, time.to_s,
class: "#{html_class} js-timeago js-timeago-pending", class: "#{html_class} js-timeago js-timeago-pending",
datetime: time.getutc.iso8601, datetime: time.getutc.iso8601,
title: time.in_time_zone.strftime('%b %-d, %Y %-I:%m%P'), # Aug 1, 2011 9:23pm title: time.in_time_zone.to_s(:medium),
data: { toggle: 'tooltip', placement: placement, container: 'body' } data: { toggle: 'tooltip', placement: placement, container: 'body' }
unless skip_js unless skip_js
......
...@@ -121,9 +121,9 @@ class GlobalMilestone ...@@ -121,9 +121,9 @@ class GlobalMilestone
def expires_at def expires_at
if due_date if due_date
if due_date.past? if due_date.past?
"expired at #{due_date.strftime('%b %-d, %Y')}" "expired on #{due_date.to_s(:medium)}"
else else
"expires at #{due_date.strftime('%b %-d, %Y')}" "expires on #{due_date.to_s(:medium)}"
end end
end end
end end
......
...@@ -112,9 +112,9 @@ class Milestone < ActiveRecord::Base ...@@ -112,9 +112,9 @@ class Milestone < ActiveRecord::Base
def expires_at def expires_at
if due_date if due_date
if due_date.past? if due_date.past?
"expired at #{due_date.strftime('%b %-d, %Y')}" "expired on #{due_date.to_s(:medium)}"
else else
"expires at #{due_date.strftime('%b %-d, %Y')}" "expires on #{due_date.to_s(:medium)}"
end end
end end
end end
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
%li %li
%span.light Created on: %span.light Created on:
%strong %strong
= @group.created_at.strftime('%B %-d, %Y') = @group.created_at.to_s(:medium)
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
%li %li
%span.light Created on: %span.light Created on:
%strong %strong
= @project.created_at.strftime('%B %-d, %Y') = @project.created_at.to_s(:medium)
%li %li
%span.light http: %span.light http:
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
%ul.well-list %ul.well-list
%li %li
%span.light Member since %span.light Member since
%strong= user.created_at.strftime('%b %-d, %Y') %strong= user.created_at.to_s(:medium)
- unless user.public_email.blank? - unless user.public_email.blank?
%li %li
%span.light E-mail: %span.light E-mail:
......
...@@ -58,12 +58,12 @@ ...@@ -58,12 +58,12 @@
%li %li
%span.light Member since: %span.light Member since:
%strong %strong
= @user.created_at.strftime('%b %-d, %Y') = @user.created_at.to_s(:medium)
- if @user.confirmed_at - if @user.confirmed_at
%li %li
%span.light Confirmed at: %span.light Confirmed at:
%strong %strong
= @user.confirmed_at.strftime('%b %-d, %Y') = @user.confirmed_at.to_s(:medium)
- else - else
%li %li
%span.light Confirmed: %span.light Confirmed:
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
%span.light Current sign-in at: %span.light Current sign-in at:
%strong %strong
- if @user.current_sign_in_at - if @user.current_sign_in_at
= @user.current_sign_in_at.strftime('%b %-d, %Y') = @user.current_sign_in_at.to_s(:medium)
- else - else
never never
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
%span.light Last sign-in at: %span.light Last sign-in at:
%strong %strong
- if @user.last_sign_in_at - if @user.last_sign_in_at
= @user.last_sign_in_at.strftime('%b %-d, %Y') = @user.last_sign_in_at.to_s(:medium)
- else - else
never never
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%strong= @key.title %strong= @key.title
%li %li
%span.light Created on: %span.light Created on:
%strong= @key.created_at.strftime('%b %-d, %Y') %strong= @key.created_at.to_s(:medium)
.col-md-8 .col-md-8
%p %p
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
%span %span
#{@user.bio}. #{@user.bio}.
%span %span
Member since #{@user.created_at.strftime('%b %d, %Y')} Member since #{@user.created_at.to_s(:medium)}
.cover-desc .cover-desc
- unless @user.public_email.blank? - unless @user.public_email.blank?
......
# :short - 10 Nov
# :medium - Nov 10, 2007
# :long - November 10, 2007
Date::DATE_FORMATS[:medium] = '%b %-d, %Y'
# :short - 18 Jan 06:10
# :medium - Jan 18, 2007 6:10am
# :long - January 18, 2007 06:10
Time::DATE_FORMATS[:medium] = '%b %-d, %Y %-I:%M%P'
...@@ -240,7 +240,7 @@ describe ApplicationHelper do ...@@ -240,7 +240,7 @@ describe ApplicationHelper do
describe 'time_ago_with_tooltip' do describe 'time_ago_with_tooltip' do
def element(*arguments) def element(*arguments)
Time.zone = 'UTC' Time.zone = 'UTC'
time = Time.zone.parse('2015-07-02 08:00') time = Time.zone.parse('2015-07-02 08:23')
element = helper.time_ago_with_tooltip(time, *arguments) element = helper.time_ago_with_tooltip(time, *arguments)
Nokogiri::HTML::DocumentFragment.parse(element).first_element_child Nokogiri::HTML::DocumentFragment.parse(element).first_element_child
...@@ -251,15 +251,15 @@ describe ApplicationHelper do ...@@ -251,15 +251,15 @@ describe ApplicationHelper do
end end
it 'includes the date string' do it 'includes the date string' do
expect(element.text).to eq '2015-07-02 08:00:00 UTC' expect(element.text).to eq '2015-07-02 08:23:00 UTC'
end end
it 'has a datetime attribute' do it 'has a datetime attribute' do
expect(element.attr('datetime')).to eq '2015-07-02T08:00:00Z' expect(element.attr('datetime')).to eq '2015-07-02T08:23:00Z'
end end
it 'has a formatted title attribute' do it 'has a formatted title attribute' do
expect(element.attr('title')).to eq 'Jul 02, 2015 8:00am' expect(element.attr('title')).to eq 'Jul 2, 2015 8:23am'
end end
it 'includes a default js-timeago class' do it 'includes a default js-timeago class' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment