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
element = content_tag :time, time.to_s,
class: "#{html_class} js-timeago js-timeago-pending",
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' }
unless skip_js
......
......@@ -121,9 +121,9 @@ class GlobalMilestone
def expires_at
if due_date
if due_date.past?
"expired at #{due_date.strftime('%b %-d, %Y')}"
"expired on #{due_date.to_s(:medium)}"
else
"expires at #{due_date.strftime('%b %-d, %Y')}"
"expires on #{due_date.to_s(:medium)}"
end
end
end
......
......@@ -112,9 +112,9 @@ class Milestone < ActiveRecord::Base
def expires_at
if due_date
if due_date.past?
"expired at #{due_date.strftime('%b %-d, %Y')}"
"expired on #{due_date.to_s(:medium)}"
else
"expires at #{due_date.strftime('%b %-d, %Y')}"
"expires on #{due_date.to_s(:medium)}"
end
end
end
......
......@@ -30,7 +30,7 @@
%li
%span.light Created on:
%strong
= @group.created_at.strftime('%B %-d, %Y')
= @group.created_at.to_s(:medium)
.panel.panel-default
.panel-heading
......
......@@ -38,7 +38,7 @@
%li
%span.light Created on:
%strong
= @project.created_at.strftime('%B %-d, %Y')
= @project.created_at.to_s(:medium)
%li
%span.light http:
......
......@@ -4,7 +4,7 @@
%ul.well-list
%li
%span.light Member since
%strong= user.created_at.strftime('%b %-d, %Y')
%strong= user.created_at.to_s(:medium)
- unless user.public_email.blank?
%li
%span.light E-mail:
......
......@@ -58,12 +58,12 @@
%li
%span.light Member since:
%strong
= @user.created_at.strftime('%b %-d, %Y')
= @user.created_at.to_s(:medium)
- if @user.confirmed_at
%li
%span.light Confirmed at:
%strong
= @user.confirmed_at.strftime('%b %-d, %Y')
= @user.confirmed_at.to_s(:medium)
- else
%li
%span.light Confirmed:
......@@ -74,7 +74,7 @@
%span.light Current sign-in at:
%strong
- if @user.current_sign_in_at
= @user.current_sign_in_at.strftime('%b %-d, %Y')
= @user.current_sign_in_at.to_s(:medium)
- else
never
......@@ -82,7 +82,7 @@
%span.light Last sign-in at:
%strong
- if @user.last_sign_in_at
= @user.last_sign_in_at.strftime('%b %-d, %Y')
= @user.last_sign_in_at.to_s(:medium)
- else
never
......
......@@ -10,7 +10,7 @@
%strong= @key.title
%li
%span.light Created on:
%strong= @key.created_at.strftime('%b %-d, %Y')
%strong= @key.created_at.to_s(:medium)
.col-md-8
%p
......
......@@ -21,7 +21,7 @@
%span
#{@user.bio}.
%span
Member since #{@user.created_at.strftime('%b %d, %Y')}
Member since #{@user.created_at.to_s(:medium)}
.cover-desc
- 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
describe 'time_ago_with_tooltip' do
def element(*arguments)
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)
Nokogiri::HTML::DocumentFragment.parse(element).first_element_child
......@@ -251,15 +251,15 @@ describe ApplicationHelper do
end
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
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
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
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