Merge pull request #5132 from coldrye-collaboration/bug-always-utc

[24498] Last updated information on work package is shown in UTC, always
pull/5135/head
Oliver Günther 8 years ago committed by GitHub
commit 601aea0f0b
  1. 11
      frontend/app/services/timezone-service.js
  2. 9
      frontend/app/ui_components/date/date-time-directive.js
  3. 9
      frontend/tests/unit/tests/ui_components/date-time-directive-test.js

@ -62,9 +62,16 @@ module.exports = function(ConfigurationService, I18n) {
}, },
formattedDatetime: function(datetimeString) { formattedDatetime: function(datetimeString) {
var c = TimezoneService.formattedDatetimeComponents(datetimeString);
return c[0] + ' ' + c[1];
},
formattedDatetimeComponents: function(datetimeString) {
var d = TimezoneService.parseDatetime(datetimeString); var d = TimezoneService.parseDatetime(datetimeString);
return d.format(TimezoneService.getDateFormat()) + ' ' + return [
d.format(TimezoneService.getTimeFormat()); d.format(TimezoneService.getDateFormat()),
d.format(TimezoneService.getTimeFormat())
];
}, },
toHours: function(durationString) { toHours: function(durationString) {

@ -31,11 +31,12 @@ module.exports = function($compile, TimezoneService) {
restrict: 'EA', restrict: 'EA',
replace: true, replace: true,
scope: { dateTimeValue: '=' }, scope: { dateTimeValue: '=' },
template: '<span title="{{ date }} {{ time }}"><op-date date-value="dateTimeValue" hide-title="true"></op-date> <op-time time-value="dateTimeValue" hide-title="true"></op-time></span>', // Note: we cannot reuse op-date here as this does not apply the user's configured timezone
template: '<span title="{{ date }} {{ time }}"><span>{{date}}</span> <span>{{time}}</span></span>',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
scope.date = TimezoneService.formattedDate(scope.dateTimeValue); var c = TimezoneService.formattedDatetimeComponents(scope.dateTimeValue);
scope.time = TimezoneService.formattedTime(scope.dateTimeValue); scope.date = c[0];
scope.time = c[1];
$compile(element.contents())(scope); $compile(element.contents())(scope);
} }
}; };

@ -49,7 +49,7 @@ describe('date time Directives', function() {
beforeEach(inject(function($rootScope, $compile, _I18n_, _TimezoneService_) { beforeEach(inject(function($rootScope, $compile, _I18n_, _TimezoneService_) {
scope = $rootScope.$new(); scope = $rootScope.$new();
scope.testDateTime = "2013-02-08T09:30:26"; scope.testDateTime = "2013-02-08T09:30:26Z";
compile = function(html) { compile = function(html) {
element = $compile(html)(scope); element = $compile(html)(scope);
@ -82,6 +82,7 @@ describe('date time Directives', function() {
describe('without configuration', function() { describe('without configuration', function() {
beforeEach(function() { beforeEach(function() {
configurationService.isTimezoneSet = sinon.stub().returns(false);
configurationService.dateFormatPresent = sinon.stub().returns(false); configurationService.dateFormatPresent = sinon.stub().returns(false);
compile(html); compile(html);
@ -96,6 +97,7 @@ describe('date time Directives', function() {
describe('with configuration', function() { describe('with configuration', function() {
beforeEach(function() { beforeEach(function() {
configurationService.isTimezoneSet = sinon.stub().returns(false);
configurationService.dateFormatPresent = sinon.stub().returns(true); configurationService.dateFormatPresent = sinon.stub().returns(true);
configurationService.dateFormat = sinon.stub().returns("DD-MM-YYYY"); configurationService.dateFormat = sinon.stub().returns("DD-MM-YYYY");
@ -129,6 +131,7 @@ describe('date time Directives', function() {
describe('with configuration', function() { describe('with configuration', function() {
beforeEach(function() { beforeEach(function() {
configurationService.isTimezoneSet = sinon.stub().returns(false);
configurationService.timeFormatPresent = sinon.stub().returns(true); configurationService.timeFormatPresent = sinon.stub().returns(true);
configurationService.timeFormat = sinon.stub().returns("HH:mm a"); configurationService.timeFormat = sinon.stub().returns("HH:mm a");
@ -159,10 +162,11 @@ describe('date time Directives', function() {
describe('without configuration', function() { describe('without configuration', function() {
beforeEach(function() { beforeEach(function() {
configurationService.isTimezoneSet = sinon.stub().returns(false);
configurationService.dateFormatPresent = sinon.stub().returns(false); configurationService.dateFormatPresent = sinon.stub().returns(false);
configurationService.timeFormatPresent = sinon.stub().returns(false); configurationService.timeFormatPresent = sinon.stub().returns(false);
scope.dateTimeValue = "2013-02-08T09:30:26"; scope.dateTimeValue = "2013-02-08T09:30:26Z";
compile(html); compile(html);
}); });
@ -177,6 +181,7 @@ describe('date time Directives', function() {
describe('with configuration', function() { describe('with configuration', function() {
beforeEach(function() { beforeEach(function() {
configurationService.isTimezoneSet = sinon.stub().returns(false);
configurationService.dateFormatPresent = sinon.stub().returns(true); configurationService.dateFormatPresent = sinon.stub().returns(true);
configurationService.timeFormatPresent = sinon.stub().returns(true); configurationService.timeFormatPresent = sinon.stub().returns(true);
configurationService.dateFormat = sinon.stub().returns("DD-MM-YYYY"); configurationService.dateFormat = sinon.stub().returns("DD-MM-YYYY");

Loading…
Cancel
Save