ai-admin-jqadm icon indicating copy to clipboard operation
ai-admin-jqadm copied to clipboard

Timezone

Open exemplari opened this issue 4 years ago • 1 comments

Is your feature request related to a problem? No

Describe the solution you'd like Local timezone configuration

Describe alternatives you've considered php.ini timezone - template files -

Additional context Particularly in the jqadm. I've seen the dates are plain text in utc Replacing them with some php date fixes several places of concern /common/partials/listsearch-standard has some date functions done in vuejs, which are still functioning in UTC how can i use local time without rewriting these vuejs list search filters?

exemplari avatar Jan 26 '21 08:01 exemplari

There's no timezone support and automatic time conversion based on the PHP timezone configuration.

In the admin backend and frontend, the date/time values should be converted to the time zone of the user, not that of the server so the PHP timezone setting isn't the right approach. Instead, the date/time values should be translated by the browser to the user timezone while still stored as UTC values in the database.

We appreciate any help for that task :-)

aimeos avatar Jan 26 '21 09:01 aimeos

I ended up with injecting this into admin. Not very flexible but could be updated.


/**
 * Aimeos timezone setup
 */
Aimeos.Api.setupTimezone = function () {
    const dateClass = '.meta-value, td[class$="-ctime"],td[class$="-mtime"], \
		td.order-datepayment, td.order-datedelivery, td.product-datestart, td.product-dateend';
    $(dateClass).each(function (el) {
        var $this = $(this);
        var dateStr = $this.text();
        if (dateStr.indexOf('-') > 0 && dateStr.indexOf(':') > 0) {
            const dayTimePart = dateStr.split(' ');
            const dayPart = dayTimePart[0].split('-');
            const timePart = dayTimePart[1].split(':');
            date = new Date(Date.UTC(dayPart[0], (dayPart[1] - 1), dayPart[2], timePart[0], timePart[1], timePart[2]));
            var dateStamp = date.toLocaleString('en-US', { hour12: true });
            var update = $this
            const contents = $this.find(':not(:has(*))')
            if (contents.length) {
                update = contents
            }
            update.text(dateStamp);
        }
    });
};


exemplari avatar Aug 23 '22 01:08 exemplari