%-d instead of %e in date formatting
Change-Id: Ice15ad81e618c5acc4974e204d2c0ccba6da4486 Reviewed-on: https://gerrit.instructure.com/11379 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
a60cbbc754
commit
043de4612e
|
@ -1,13 +1,14 @@
|
|||
Time.class_eval do
|
||||
if RUBY_VERSION < "1.9."
|
||||
def strftime_with_1_9_parity(string)
|
||||
string = string.gsub(/%[369]?N|%./) do |match|
|
||||
string = string.gsub(/%(%|-?[a-zA-Z]|[369]N)/) do |match|
|
||||
case match
|
||||
when '%L', '%3N'; ("%.3f" % (to_f % 1))[2, 3]
|
||||
when '%6N'; ("%.6f" % (to_f % 1))[2, 6]
|
||||
when '%N', '%9N'; ("%.9f" % (to_f % 1))[2, 9]
|
||||
when '%P'; strftime_without_1_9_parity('%p').downcase
|
||||
when '%v'; '%e-%b-%Y'
|
||||
when '%-d'; strftime_without_1_9_parity('%d').sub(/^0+/, '')
|
||||
else match
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,8 +2,8 @@ en:
|
|||
date:
|
||||
formats:
|
||||
weekday: "%A"
|
||||
medium: "%b %e, %Y"
|
||||
short: "%b %e"
|
||||
medium: "%b %-d, %Y"
|
||||
short: "%b %-d"
|
||||
short_month: "%b"
|
||||
medium_month: "%b %Y"
|
||||
days:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
// this file was auto-generated by rake i18n:generate_js.
|
||||
// you probably shouldn't edit it directly
|
||||
define(['i18nObj', 'jquery'], function(I18n, $) {
|
||||
$.extend(true, I18n, {translations: {"en":{"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"days":{"today":"Today","today_lower":"today","tomorrow":"Tomorrow","yesterday":"Yesterday"},"formats":{"default":"%Y-%m-%d","long":"%B %d, %Y","medium":"%b %e, %Y","medium_month":"%b %Y","short":"%b %e","short_month":"%b","weekday":"%A"},"month_names":[null,"January","February","March","April","May","June","July","August","September","October","November","December"],"order":["year","month","day"]},"datetime":{"distance_in_words":{"about_x_hours":{"one":"about 1 hour","other":"about %{count} hours"},"about_x_months":{"one":"about 1 month","other":"about %{count} months"},"about_x_years":{"one":"about 1 year","other":"about %{count} years"},"almost_x_years":{"one":"almost 1 year","other":"almost %{count} years"},"half_a_minute":"half a minute","less_than_x_minutes":{"one":"less than a minute","other":"less than %{count} minutes"},"less_than_x_seconds":{"one":"less than 1 second","other":"less than %{count} seconds"},"over_x_years":{"one":"over 1 year","other":"over %{count} years"},"x_days":{"one":"1 day","other":"%{count} days"},"x_minutes":{"one":"1 minute","other":"%{count} minutes"},"x_months":{"one":"1 month","other":"%{count} months"},"x_seconds":{"one":"1 second","other":"%{count} seconds"}},"prompts":{"day":"Day","hour":"Hour","minute":"Minute","month":"Month","second":"Seconds","year":"Year"}},"number":{"currency":{"format":{"delimiter":",","format":"%u%n","precision":2,"separator":".","unit":"$"}},"format":{"delimiter":",","precision":3,"separator":"."},"human":{"format":{"delimiter":"","precision":1},"storage_units":{"format":"%n %u","units":{"byte":{"one":"Byte","other":"Bytes"},"gb":"GB","kb":"KB","mb":"MB","tb":"TB"}}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}}},"support":{"array":{"last_word_connector":", and ","or":{"last_word_connector":", or ","two_words_connector":" or "},"two_words_connector":" and ","words_connector":", "},"select":{"prompt":"Please select"}},"time":{"am":"am","count_hours_ago":{"one":"1 hour ago","other":"%{count} hours ago"},"count_minutes_ago":{"one":"1 minute ago","other":"%{count} minutes ago"},"due_date":"%{date} by %{time}","event":"%{date} at %{time}","formats":{"default":"%a, %d %b %Y %H:%M:%S %z","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","tiny":"%l:%M%P","tiny_on_the_hour":"%l%P"},"less_than_a_minute_ago":"less than a minute ago","pm":"pm","ranges":{"different_days":"%{start_date_and_time} to %{end_date_and_time}","same_day":"%{date} from %{start_time} to %{end_time}","times":"%{start_time} to %{end_time}"},"unknown_date":"Unknown date","with_ago":"%{time} ago"}}}});
|
||||
$.extend(true, I18n, {translations: {"en":{"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"days":{"today":"Today","today_lower":"today","tomorrow":"Tomorrow","yesterday":"Yesterday"},"formats":{"default":"%Y-%m-%d","long":"%B %d, %Y","medium":"%b %-d, %Y","medium_month":"%b %Y","short":"%b %-d","short_month":"%b","weekday":"%A"},"month_names":[null,"January","February","March","April","May","June","July","August","September","October","November","December"],"order":["year","month","day"]},"datetime":{"distance_in_words":{"about_x_hours":{"one":"about 1 hour","other":"about %{count} hours"},"about_x_months":{"one":"about 1 month","other":"about %{count} months"},"about_x_years":{"one":"about 1 year","other":"about %{count} years"},"almost_x_years":{"one":"almost 1 year","other":"almost %{count} years"},"half_a_minute":"half a minute","less_than_x_minutes":{"one":"less than a minute","other":"less than %{count} minutes"},"less_than_x_seconds":{"one":"less than 1 second","other":"less than %{count} seconds"},"over_x_years":{"one":"over 1 year","other":"over %{count} years"},"x_days":{"one":"1 day","other":"%{count} days"},"x_minutes":{"one":"1 minute","other":"%{count} minutes"},"x_months":{"one":"1 month","other":"%{count} months"},"x_seconds":{"one":"1 second","other":"%{count} seconds"}},"prompts":{"day":"Day","hour":"Hour","minute":"Minute","month":"Month","second":"Seconds","year":"Year"}},"number":{"currency":{"format":{"delimiter":",","format":"%u%n","precision":2,"separator":".","unit":"$"}},"format":{"delimiter":",","precision":3,"separator":"."},"human":{"format":{"delimiter":"","precision":1},"storage_units":{"format":"%n %u","units":{"byte":{"one":"Byte","other":"Bytes"},"gb":"GB","kb":"KB","mb":"MB","tb":"TB"}}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}}},"support":{"array":{"last_word_connector":", and ","or":{"last_word_connector":", or ","two_words_connector":" or "},"two_words_connector":" and ","words_connector":", "},"select":{"prompt":"Please select"}},"time":{"am":"am","count_hours_ago":{"one":"1 hour ago","other":"%{count} hours ago"},"count_minutes_ago":{"one":"1 minute ago","other":"%{count} minutes ago"},"due_date":"%{date} by %{time}","event":"%{date} at %{time}","formats":{"default":"%a, %d %b %Y %H:%M:%S %z","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","tiny":"%l:%M%P","tiny_on_the_hour":"%l%P"},"less_than_a_minute_ago":"less than a minute ago","pm":"pm","ranges":{"different_days":"%{start_date_and_time} to %{end_date_and_time}","same_day":"%{date} from %{start_time} to %{end_time}","times":"%{start_time} to %{end_time}"},"unknown_date":"Unknown date","with_ago":"%{time} ago"}}}});
|
||||
});
|
||||
|
|
|
@ -36,7 +36,7 @@ describe TextHelper do
|
|||
|
||||
it "should just give the start if no end is provided" do
|
||||
datetime = Time.zone.parse("#{Time.zone.now.year}-01-01 12:00:00")
|
||||
th.datetime_string(datetime).should == "Jan 1 at 12pm"
|
||||
th.datetime_string(datetime).should == "Jan 1 at 12pm"
|
||||
end
|
||||
|
||||
it "should omit the time if shorten_midnight is true and it's (due) at midnight" do
|
||||
|
@ -48,7 +48,7 @@ describe TextHelper do
|
|||
|
||||
it "should ignore end if the type is due_date" do
|
||||
datetime = Time.zone.parse("#{Time.now.year}-01-01 12:00:00")
|
||||
expected = "Jan 1 by 12pm"
|
||||
expected = "Jan 1 by 12pm"
|
||||
th.datetime_string(datetime, :due_date).should == expected
|
||||
th.datetime_string(datetime, :due_date, datetime + 1.hour).should == expected
|
||||
end
|
||||
|
@ -57,14 +57,14 @@ describe TextHelper do
|
|||
start_datetime = Time.zone.parse("#{Time.zone.now.year}-01-01 12:00:00")
|
||||
end_datetime = start_datetime + 2.days
|
||||
th.datetime_string(start_datetime, :event, end_datetime).should ==
|
||||
"Jan 1 at 12pm to Jan 3 at 12pm"
|
||||
"Jan 1 at 12pm to Jan 3 at 12pm"
|
||||
end
|
||||
|
||||
it "should give a same-day range if start and end are on the same day" do
|
||||
start_datetime = Time.zone.parse("#{Time.zone.now.year}-01-01 12:00:00")
|
||||
end_datetime = start_datetime.advance(:hours => 1)
|
||||
th.datetime_string(start_datetime, :event, end_datetime).should ==
|
||||
"Jan 1 from 12pm to 1pm"
|
||||
"Jan 1 from 12pm to 1pm"
|
||||
end
|
||||
|
||||
it "should include the year if the current year isn't the same" do
|
||||
|
|
|
@ -121,7 +121,7 @@ describe ConversationMessage do
|
|||
student.user_notes.size.should be(1)
|
||||
student.user_notes.first.should eql(note)
|
||||
note.creator.should eql(@teacher)
|
||||
note.title.should eql("Private message, Jan 1, 1970")
|
||||
note.title.should eql("Private message, Jan 1, 1970")
|
||||
note.note.should eql("reprimanded!")
|
||||
end
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ describe "i18n js" do
|
|||
context "strftime" do
|
||||
it "should format just like ruby" do
|
||||
# everything except %N %6N %9N %U %V %W %Z
|
||||
format = "%a %A %b %B %d %D %e %F %h %H %I %j %k %l %L %m %M %n %3N %p %P %r %R %s %S %t %T %u %v %w %y %Y %z %%"
|
||||
format = "%a %A %b %B %d %-d %D %e %F %h %H %I %j %k %l %L %m %M %n %3N %p %P %r %R %s %S %t %T %u %v %w %y %Y %z %%"
|
||||
date = Time.now
|
||||
driver.execute_script(<<-JS).should == date.strftime(format)
|
||||
var date = new Date(#{date.strftime('%s')} * 1000 + #{date.strftime('%L').gsub(/^0+/, '')});
|
||||
|
|
Loading…
Reference in New Issue