Switching to using moment.js for times in JS, rather than a custom solution. Fixes #688
This commit is contained in:
parent
3f15c0618a
commit
5e7301d662
|
@ -33,6 +33,11 @@ class Lang
|
|||
print call_user_func_array(array('PHPCI\Helper\Lang', 'get'), func_get_args());
|
||||
}
|
||||
|
||||
public static function getLanguage()
|
||||
{
|
||||
return self::$language;
|
||||
}
|
||||
|
||||
public static function getStrings()
|
||||
{
|
||||
return self::$strings;
|
||||
|
|
|
@ -82,6 +82,7 @@ PHPCI',
|
|||
'success' => 'Success',
|
||||
'successful' => 'Successful',
|
||||
'failed' => 'Failed',
|
||||
'manual_build' => 'Manual Build',
|
||||
|
||||
// Add/Edit Project:
|
||||
'new_project' => 'New Project',
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
<script>
|
||||
var PHPCI_URL = '<?php print PHPCI_URL; ?>';
|
||||
var PHPCI_LANGUAGE = <?php print json_encode(Lang::getLanguage()); ?>;
|
||||
|
||||
<?php if (defined('JSON_UNESCAPED_UNICODE')): ?>
|
||||
var PHPCI_STRINGS = <?php print json_encode(Lang::getStrings(), JSON_UNESCAPED_UNICODE); ?>;
|
||||
|
@ -30,6 +31,7 @@
|
|||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
|
||||
<script src="<?php print PHPCI_URL; ?>assets/js/class.js"></script>
|
||||
<script src="<?php print PHPCI_URL; ?>assets/js/sprintf.js"></script>
|
||||
<script src="<?php print PHPCI_URL; ?>assets/js/moment.min.js"></script>
|
||||
<script src="<?php print PHPCI_URL; ?>assets/js/phpci.js" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
|
||||
|
|
|
@ -14,15 +14,15 @@ var timePlugin = ActiveBuild.UiPlugin.extend({
|
|||
var finished = '';
|
||||
|
||||
if (ActiveBuild.buildData.created) {
|
||||
created = dateFormat(ActiveBuild.buildData.created);
|
||||
created = moment(ActiveBuild.buildData.created).format('ll LT');
|
||||
}
|
||||
|
||||
if (ActiveBuild.buildData.started) {
|
||||
started = dateFormat(ActiveBuild.buildData.started);
|
||||
started = moment(ActiveBuild.buildData.started).format('ll LT');
|
||||
}
|
||||
|
||||
if (ActiveBuild.buildData.finished) {
|
||||
finished = dateFormat(ActiveBuild.buildData.finished);
|
||||
finished = moment(ActiveBuild.buildData.finished).format('ll LT');
|
||||
}
|
||||
|
||||
return '<table class="table table-striped table-bordered">' +
|
||||
|
@ -51,15 +51,15 @@ var timePlugin = ActiveBuild.UiPlugin.extend({
|
|||
var finished = '';
|
||||
|
||||
if (build.created) {
|
||||
created = dateFormat(build.created);
|
||||
created = moment(build.created).format('ll LT');
|
||||
}
|
||||
|
||||
if (build.started) {
|
||||
started = dateFormat(build.started);
|
||||
started = moment(build.started).format('ll LT');
|
||||
}
|
||||
|
||||
if (build.finished) {
|
||||
finished = dateFormat(build.finished);
|
||||
finished = moment(build.finished).format('ll LT');
|
||||
}
|
||||
|
||||
$('#created').text(created);
|
||||
|
|
10
public/assets/js/moment.min.js
vendored
Normal file
10
public/assets/js/moment.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -407,73 +407,6 @@ function setupProjectForm()
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
function dateFormat(date)
|
||||
{
|
||||
if (typeof date == 'string') {
|
||||
date = new Date(date);
|
||||
}
|
||||
|
||||
var rtn = '';
|
||||
|
||||
switch (date.getMonth()) {
|
||||
case 0:
|
||||
rtn = 'Jan ';
|
||||
break;
|
||||
|
||||
case 1:
|
||||
rtn = 'Feb ';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
rtn = 'Mar ';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
rtn = 'Apr ';
|
||||
break;
|
||||
|
||||
case 4:
|
||||
rtn = 'May ';
|
||||
break;
|
||||
|
||||
case 5:
|
||||
rtn = 'Jun ';
|
||||
break;
|
||||
|
||||
case 6:
|
||||
rtn = 'Jul ';
|
||||
break;
|
||||
|
||||
case 7:
|
||||
rtn = 'Aug ';
|
||||
break;
|
||||
|
||||
case 8:
|
||||
rtn = 'Sep ';
|
||||
break;
|
||||
|
||||
case 9:
|
||||
rtn = 'Oct ';
|
||||
break;
|
||||
|
||||
case 10:
|
||||
rtn = 'Nov ';
|
||||
break;
|
||||
|
||||
case 11:
|
||||
rtn = 'Dec ';
|
||||
break;
|
||||
}
|
||||
|
||||
rtn += date.getDate() + ' ' + date.getFullYear();
|
||||
rtn += ' ' + date.getHours() + ':' + date.getMinutes();
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
|
||||
var Lang = {
|
||||
get: function () {
|
||||
var args = Array.prototype.slice.call(arguments);;
|
||||
|
@ -486,4 +419,6 @@ var Lang = {
|
|||
|
||||
return 'MISSING: ' + string;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
moment.locale(PHPCI_LANGUAGE);
|
Loading…
Reference in a new issue