Changeset 654 for trunk/js


Ignore:
Timestamp:
Jan 24, 2019 7:13:52 PM (5 years ago)
Author:
anonymous
Message:

Add timezone support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/js/Utilities.js

    r590 r654  
    6565        $(this).text($(this).text().replace(' at ', '@').replace(' dot ', '.'));
    6666        if (this.href) {
    67             this.href = this.href.replace(' at ', '@').replace(' dot ', '.');
     67            this.href = decodeURIComponent(this.href).replace(' at ', '@').replace(' dot ', '.');
    6868        }
    6969    });
     
    100100};
    101101
     102/*
     103* Set the user's timezone in a cookie (which is used in Codebase's $app->start() method).
     104---------------------------------------------------------------------
     105Strangecode.setTimezoneCookie()
     106---------------------------------------------------------------------
     107* @access   public
     108* @version  1.0
     109* @since    24 Jan 2019
     110*/
     111Strangecode.setTimezoneCookie = function () {
     112    try {
     113        // use Intl API when available and returning valid time zone
     114        var tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
     115    } catch (e) {
     116        // Intl unavailable, fall back to manual guessing.
     117        tz = (new Date().getTimezoneOffset()/-60);
     118    }
     119    if ('' != tz) {
     120        document.cookie = 'tz=' + tz + ';path=/;max-age=86400';
     121    }
     122}
    102123
    103124/*
Note: See TracChangeset for help on using the changeset viewer.