Fix Angular mediumDateFilter
Angular mediumDateFilter provides user with a readable date format using predefined localizable format "medium". However it should be more flexible with different types of inputs. This patch fixes the filter and applies it at the images overview page. Change-Id: I7079c306c6f98f13c779e6dae7357ccabba2d460 Closes-Bug: #1841049
This commit is contained in:
parent
f00f013f16
commit
71ed12f622
@ -85,7 +85,10 @@
|
||||
* For the input time, we need to add "Z" to fit iso8601 time format
|
||||
* so the filter can confirm that the input time is in UTC timezone.
|
||||
*/
|
||||
input = input + 'Z';
|
||||
input = $filter('noValue')(input);
|
||||
if (input !== '-') {
|
||||
input = input.slice(-1) !== 'Z' ? input + 'Z' : input;
|
||||
}
|
||||
var currentTimeZone = $cookies.get('django_timezone') || 'UTC';
|
||||
currentTimeZone = currentTimeZone.replace(/^"(.*)"$/, '$1');
|
||||
return timeZoneService.getTimeZoneOffset(currentTimeZone).then(function (timeZoneOffset) {
|
||||
|
@ -90,7 +90,15 @@
|
||||
});
|
||||
|
||||
it('returns the expected time', function() {
|
||||
mediumDateFilter().then(getResult);
|
||||
mediumDateFilter('2019-09-03T09:19:07.000').then(getResult);
|
||||
|
||||
function getResult(result) {
|
||||
expect(result).toBe('Sep 3, 2019 9:19:07 AM');
|
||||
}
|
||||
});
|
||||
|
||||
it('returns the expected time in UTC', function() {
|
||||
mediumDateFilter('2019-09-03T09:19:07.000Z').then(getResult);
|
||||
|
||||
function getResult(result) {
|
||||
expect(result).toBe('Sep 3, 2019 9:19:07 AM');
|
||||
|
@ -245,14 +245,14 @@
|
||||
name: gettext('Name'),
|
||||
owner: gettext('Owner'),
|
||||
tags: gettext('Tags'),
|
||||
'updated_at': {label: gettext('Updated At'), filters: ['simpleDate'] },
|
||||
'updated_at': {label: gettext('Updated At'), filters: ['mediumDate'] },
|
||||
virtual_size: gettext('Virtual Size'),
|
||||
visibility: gettext('Visibility'),
|
||||
description: gettext('Description'),
|
||||
architecture: gettext('Architecture'),
|
||||
kernel_id: gettext('Kernel ID'),
|
||||
ramdisk_id: gettext('Ramdisk ID'),
|
||||
'created_at': {label: gettext('Created At'), filters: ['simpleDate'] },
|
||||
'created_at': {label: gettext('Created At'), filters: ['mediumDate'] },
|
||||
container_format: { label: gettext('Container Format'), filters: ['uppercase'] },
|
||||
disk_format: { label: gettext('Disk Format'), filters: ['noValue', 'uppercase'] },
|
||||
is_public: { label: gettext('Is Public'), filters: ['yesno'] },
|
||||
|
Loading…
Reference in New Issue
Block a user