Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
55
gaia/apps/calendar/js/templates/duration_time.js
Executable file
55
gaia/apps/calendar/js/templates/duration_time.js
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
define(function(require, exports, module) {
|
||||
'use strict';
|
||||
|
||||
var Calc = require('common/calc');
|
||||
var DateSpan = require('templates/date_span');
|
||||
var create = require('template').create;
|
||||
|
||||
var l10n = navigator.mozL10n;
|
||||
|
||||
module.exports = create({
|
||||
durationTime: function() {
|
||||
var format = '';
|
||||
var startDate = this.arg('startDate');
|
||||
var endDate = this.arg('endDate');
|
||||
var isAllDay = this.arg('isAllDay');
|
||||
|
||||
if (isAllDay) {
|
||||
// Use the last second of previous day as the base for endDate
|
||||
// (e.g., 1991-09-14T23:59:59 insteads of 1991-09-15T00:00:00).
|
||||
endDate = new Date(endDate - 1000);
|
||||
format = Calc.isSameDate(startDate, endDate) ?
|
||||
'one-all-day-duration' :
|
||||
'multiple-all-day-duration';
|
||||
} else {
|
||||
format = Calc.isSameDate(startDate, endDate) ?
|
||||
'one-day-duration' :
|
||||
'multiple-day-duration';
|
||||
}
|
||||
|
||||
return l10n.get(format, {
|
||||
startTime: formatTime(startDate),
|
||||
startDate: formatDate(startDate),
|
||||
endTime: formatTime(endDate),
|
||||
endDate: formatDate(endDate)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function formatDate(date) {
|
||||
return date.toLocaleString(navigator.languages, {
|
||||
weekday: 'long',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
year: 'numeric'
|
||||
});
|
||||
}
|
||||
|
||||
function formatTime(time) {
|
||||
return DateSpan.time.render({
|
||||
time: time,
|
||||
format: 'shortTimeFormat'
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue