mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
fix not working et2-date-since and rename et2-date-time_today to et2-date-time-today
create a new method egw.getTimezoneOffset() return current offset according to user preferences on server-side, like (new Date).getTimezoneOffset()
This commit is contained in:
parent
2442e80cea
commit
3eaed09185
@ -13,7 +13,7 @@
|
|||||||
use EGroupware\Api;
|
use EGroupware\Api;
|
||||||
|
|
||||||
// add et2- prefix to following widgets/tags
|
// add et2- prefix to following widgets/tags
|
||||||
const ADD_ET2_PREFIX_REGEXP = '#<((/?)([vh]?box|date(-time[^\s]*|-duration)?|textbox|textarea|button|colorpicker|description|image|url(-email|-phone|-fax)?))(/?|\s[^>]*)>#m';
|
const ADD_ET2_PREFIX_REGEXP = '#<((/?)([vh]?box|date(-time[^\s]*|-duration|-since)?|textbox|textarea|button|colorpicker|description|image|url(-email|-phone|-fax)?))(/?|\s[^>]*)>#m';
|
||||||
const ADD_ET2_PREFIX_LAST_GROUP = 6;
|
const ADD_ET2_PREFIX_LAST_GROUP = 6;
|
||||||
|
|
||||||
// switch evtl. set output-compression off, as we cant calculate a Content-Length header with transparent compression
|
// switch evtl. set output-compression off, as we cant calculate a Content-Length header with transparent compression
|
||||||
@ -92,7 +92,11 @@ function send_template()
|
|||||||
// eTemplate marked as legacy --> replace only some widgets (eg. requiring jQueryUI) with web-components
|
// eTemplate marked as legacy --> replace only some widgets (eg. requiring jQueryUI) with web-components
|
||||||
if (preg_match('/<overlay[^>]* legacy="true"/', $str))
|
if (preg_match('/<overlay[^>]* legacy="true"/', $str))
|
||||||
{
|
{
|
||||||
$str = preg_replace('#<date(-time[^\s]*|-duration)?\s([^>]+)/>#', '<et2-date$1 $2></et2-date$1>', $str);
|
$str = preg_replace_callback('#<date(-time[^\s]*|-duration|-since)?\s([^>]+)/>#', static function($matches)
|
||||||
|
{
|
||||||
|
if ($matches[1] === 'date-time_today') $matches[1] = 'date-time-today';
|
||||||
|
return "<et2-date$matches[1] $matches[2]></et2-date$matches[1]>";
|
||||||
|
}, $str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -211,6 +215,7 @@ function send_template()
|
|||||||
}, $str);
|
}, $str);
|
||||||
|
|
||||||
$str = preg_replace_callback(ADD_ET2_PREFIX_REGEXP, static function (array $matches) {
|
$str = preg_replace_callback(ADD_ET2_PREFIX_REGEXP, static function (array $matches) {
|
||||||
|
if ($matches[3] === 'date-time_today') $matches[3] = 'date-time-today';
|
||||||
return '<' . $matches[2] . 'et2-' . $matches[3] .
|
return '<' . $matches[2] . 'et2-' . $matches[3] .
|
||||||
// web-components must not be self-closing (no "<et2-button .../>", but "<et2-button ...></et2-button>")
|
// web-components must not be self-closing (no "<et2-button .../>", but "<et2-button ...></et2-button>")
|
||||||
(substr($matches[ADD_ET2_PREFIX_LAST_GROUP], -1) === '/' ? substr($matches[ADD_ET2_PREFIX_LAST_GROUP], 0, -1) .
|
(substr($matches[ADD_ET2_PREFIX_LAST_GROUP], -1) === '/' ? substr($matches[ADD_ET2_PREFIX_LAST_GROUP], 0, -1) .
|
||||||
|
@ -37,7 +37,7 @@ const formatDate = function(date : Date, options = {units: "YmdHis"})
|
|||||||
's': 1
|
's': 1
|
||||||
};
|
};
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var diff = Math.round(d.valueOf() / 1000) - Math.round(date.valueOf() / 1000);
|
var diff = Math.round(d.valueOf() / 1000) - Math.round(date.valueOf() / 1000 + egw.getTimezoneOffset() * 60);
|
||||||
let display = '';
|
let display = '';
|
||||||
|
|
||||||
// limit units used to display
|
// limit units used to display
|
||||||
|
@ -12,7 +12,7 @@ import {Et2DateReadonly} from "./Et2DateReadonly";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget displays date/time with different formatting relative to today
|
* Widget displays date/time with different formatting relative to today
|
||||||
* If the date is today, we show just the time. Otherwise, full date + time.
|
* If the date is today, we show just the time, otherwise just the date.
|
||||||
*/
|
*/
|
||||||
export class Et2DateTimeToday extends Et2DateReadonly
|
export class Et2DateTimeToday extends Et2DateReadonly
|
||||||
{
|
{
|
||||||
@ -39,14 +39,14 @@ export class Et2DateTimeToday extends Et2DateReadonly
|
|||||||
{
|
{
|
||||||
display = formatTime(date);
|
display = formatTime(date);
|
||||||
}
|
}
|
||||||
// Before today - date and time
|
// Before today - just the date
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
display = formatDateTime(date);
|
display = formatDate(date);
|
||||||
}
|
}
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore TypeScript is not recognizing that this is a LitElement
|
// @ts-ignore TypeScript is not recognizing that this is a LitElement
|
||||||
customElements.define("et2-date-time_today", Et2DateTimeToday);
|
customElements.define("et2-date-time-today", Et2DateTimeToday);
|
@ -36,7 +36,7 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
.replace("m","mm")
|
.replace("m","mm")
|
||||||
.replace("M", "M")
|
.replace("M", "M")
|
||||||
.replace('H', 'hh')
|
.replace('H', 'hh')
|
||||||
.replace('i', 'mm') // datepicker uses mm for month and minutes, depending where in format it's written!
|
.replace('i', 'mm') // datepicker uses mm for month and minutes, depending on where in format it's written!
|
||||||
.replace('s', 'ss');
|
.replace('s', 'ss');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +77,21 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
{
|
{
|
||||||
return dateTimeFormat(_php_format);
|
return dateTimeFormat(_php_format);
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get timezone offset of user in seconds
|
||||||
|
*
|
||||||
|
* If browser / OS is configured correct, identical to: (new Date()).getTimezoneOffset()
|
||||||
|
*
|
||||||
|
* @return {number} offset to UTC in seconds
|
||||||
|
*/
|
||||||
|
getTimezoneOffset: function() {
|
||||||
|
return isNaN(egw.preference('timezoneoffset')) ? (new Date()).getTimezoneOffset() : parseInt(egw.preference('timezoneoffset'));
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Calculate the start of the week, according to user's preference
|
* Calculate the start of the week, according to user's preference
|
||||||
*
|
*
|
||||||
* @param {string} date
|
* @param {string} date
|
||||||
|
* @return {Date}
|
||||||
*/
|
*/
|
||||||
week_start: function(date) {
|
week_start: function(date) {
|
||||||
var d = new Date(date);
|
var d = new Date(date);
|
||||||
|
26
api/js/jsapi/egw_global.d.ts
vendored
26
api/js/jsapi/egw_global.d.ts
vendored
@ -674,6 +674,32 @@ declare interface IegwGlobal
|
|||||||
* @param {Window|String} closed Window that was closed, or its name
|
* @param {Window|String} closed Window that was closed, or its name
|
||||||
*/
|
*/
|
||||||
windowClosed(appname : string, closed : Window|string) : void;
|
windowClosed(appname : string, closed : Window|string) : void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implemented in egw_calendar.js
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* transform PHP date/time-format to jQuery date/time-format
|
||||||
|
*
|
||||||
|
* @param {string} _php_format
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
dateTimeFormat(_php_format : string) : string;
|
||||||
|
/**
|
||||||
|
* Get timezone offset of user in seconds
|
||||||
|
*
|
||||||
|
* If browser / OS is configured correct, identical to: (new Date()).getTimezoneOffset()
|
||||||
|
*
|
||||||
|
* @return {number} offset to UTC in seconds
|
||||||
|
*/
|
||||||
|
getTimezoneOffset() : number;
|
||||||
|
/**
|
||||||
|
* Calculate the start of the week, according to user's preference
|
||||||
|
*
|
||||||
|
* @param {string} date
|
||||||
|
* @return {Date}
|
||||||
|
*/
|
||||||
|
week_start(date : string) : Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class JsonRequest
|
declare class JsonRequest
|
||||||
|
@ -31,6 +31,8 @@ $GLOBALS['egw']->session->commit_session();
|
|||||||
|
|
||||||
// use an etag over config and link-registry
|
// use an etag over config and link-registry
|
||||||
$preferences['common'] = $GLOBALS['egw_info']['user']['preferences']['common'];
|
$preferences['common'] = $GLOBALS['egw_info']['user']['preferences']['common'];
|
||||||
|
// send users timezone offset to client-side
|
||||||
|
$preferences['common']['timezoneoffset'] = -Api\DateTime::$user_timezone->getOffset(new Api\DateTime('now')) / 60;
|
||||||
foreach(['addressbook', 'notifications', 'status', 'filemanager'] as $app)
|
foreach(['addressbook', 'notifications', 'status', 'filemanager'] as $app)
|
||||||
{
|
{
|
||||||
if (!empty($GLOBALS['egw_info']['user']['apps'][$app]))
|
if (!empty($GLOBALS['egw_info']['user']['apps'][$app]))
|
||||||
|
Loading…
Reference in New Issue
Block a user