Skip to content

Commit 870c74a

Browse files
committed
use localized date strings in the timer list and apply the utc offset to the list elements
1 parent 7f83559 commit 870c74a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

js/src/timer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function() {
217217
return moment.unix(ts).format(dtf.tformat());
218218
}
219219
function getWorkItems() {
220-
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/work-intervals?from='+start.unix()+'&to='+end.unix());
220+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/work-intervals?from='+start.unix()+'&to='+end.unix()+'&tzoffset='+new Date().getTimezoneOffset());
221221
$.ajaxSetup({
222222
scriptCharset: "utf-8",
223223
//contentType: "application/json; charset=utf-8"

lib/Controller/AjaxController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use OCP\AppFramework\Http\TemplateResponse;
55
use OCP\AppFramework\Http\DataResponse;
66
use OCP\AppFramework\Controller;
7+
use OCP\IL10N;
78
use OCP\IUserSession;
89
use OCA\TimeTracker\Db\WorkIntervalMapper;
910
use OCA\TimeTracker\Db\WorkInterval;
@@ -46,8 +47,9 @@ class AjaxController extends Controller {
4647
protected $reportItemMapper;
4748
protected $timelineMapper;
4849
protected $timelineEntryMapper;
50+
protected $l10n;
4951

50-
public function __construct($AppName, IRequest $request, IUserSession $userSession,
52+
public function __construct($AppName, IRequest $request, IUserSession $userSession, IL10N $l10n,
5153
WorkIntervalMapper $workIntervalMapper, ClientMapper $clientMapper, UserToClientMapper $userToClientMapper,
5254
ProjectMapper $projectMapper, UserToProjectMapper $userToProjectMapper, TagMapper $tagMapper, WorkIntervalToTagMapper $workIntervalToTagMapper, ReportItemMapper $reportItemMapper,
5355
TimelineMapper $timelineMapper, TimelineEntryMapper $timelineEntryMapper, GoalMapper $goalMapper, $UserId){
@@ -71,6 +73,7 @@ public function __construct($AppName, IRequest $request, IUserSession $userSessi
7173
$this->timelineEntryMapper = $timelineEntryMapper;
7274

7375
$this->request = $request;
76+
$this->l10n = $l10n;
7477
}
7578

7679
/**
@@ -82,9 +85,13 @@ public function workIntervals() {
8285
$to = $this->request->to;
8386
$l = $this->workIntervalMapper->findLatestInterval($this->userId, $from, $to);
8487
$days = [];
88+
$tzoffset = 0;
89+
if (isset($this->request->tzoffset)) {
90+
$tzoffset = -($this->request->tzoffset * 60);
91+
}
92+
date_default_timezone_set('UTC');
8593
foreach ($l as $wi){
86-
//$dt = date("d/m/Y", $wi->start);
87-
$dt = date("D, j M", $wi->start);
94+
$dt = $this->l10n->l('date', $wi->start+$tzoffset, ['width' => 'medium']);
8895
if (!isset($days[$dt])){
8996
$days[$dt] = [];
9097
}

0 commit comments

Comments
 (0)