https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleFormat
505942
function localeFormat (d, format) {
        var tokens = format.match(/(%E.|%O.|%.)/g);

        for (var i = 0; tokens && i < tokens.length; i++) {
            var value = '';

            // http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html
            switch (tokens[i]) {
            // localized day/month names
            case '%a':
                value = _('weekday-' + d.getDay() + '-short');
                break;
            case '%A':
                value = _('weekday-' + d.getDay() + '-long');
                break;
            case '%b':
            case '%h':
                value = _('month-' + d.getMonth() + '-short');
                break;
            case '%B':
                value = _('month-' + d.getMonth() + '-long');
                break;
            case '%Eb':
                value = _('month-' + d.getMonth() + '-genitive');
                break;

            // like %H, but in 12-hour format and without any leading zero
            case '%I':
                value = d.getHours() % 12 || 12;
                break;

            // like %d, without any leading zero
            case '%e':
                value = d.getDate();
                break;

            // %p: 12 hours format (AM/PM)
            case '%p':
                value = d.getHours() < 12 ? _('time_am') : _('time_pm');
                break;

            // localized date/time strings
            case '%c':
            case '%x':
            case '%X':
            // ensure the localized format string doesn't contain any %c|%x|%X
                var tmp = _('dateTimeFormat_' + tokens[i]);
                if (tmp && !(/(%c|%x|%X)/).test(tmp)) {
                    value = localeFormat(d, tmp);
                }
                break;

            // other tokens don't require any localization
            }

            format = format.replace(tokens[i], value || d.toLocaleFormat(tokens[i]));
        }

        return format;
    }
149741
def getLocalDatetime(date, time, tz=None, timeDefault=dt.time.max):
    
    localTZ = timezone.get_current_timezone()
    if tz is None or tz == localTZ:
        localDt = getAwareDatetime(date, time, tz, timeDefault)
    else:
        # create in event's time zone
        eventDt = getAwareDatetime(date, time, tz, timeDefault)
        # convert to local time zone
        localDt = eventDt.astimezone(localTZ)
        if time is None:
            localDt = getAwareDatetime(localDt.date(), None, localTZ, timeDefault)
    return localDt
296217
protected LocalDate toLocalDate(@Nullable final String inputDate) {
        return inputDate == null || inputDate.isEmpty() ? null : LocalDate.parse(inputDate, LOCAL_DATE_FORMATTER);
    }
737465
function toAmzUtcString(date) {
  var pieces = new Date(date).toUTCString().match(/^(.+), (.+) (.+) (.+) (.+) GMT$/)
  return [pieces[1], pieces[3], pieces[2], pieces[5], 'UTC', pieces[4]].join(' ')
}
1098565
def getLocalTime(date, time, *args, **kwargs):
    
    if time is not None:
        return getLocalDateAndTime(date, time, *args, **kwargs)[1]
457671
function formatMonthTitle(date) {
  var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en';

  return (0, _moment2.default)(date).locale(locale).format('MMMM YYYY');
}
927171
function numberToDateName(value, type) {
    if (type == 'dow') {
      return locale.DOW[value - 1];
    } else if (type == 'mon') {
      return locale.MONTH[value - 1];
    }
  }
65061
function dateStrGetter(name, width, form, extended) {
    if (form === void 0) { form = FormStyle.Format; }
    if (extended === void 0) { extended = false; }
    return function (date, locale) {
        return getDateTranslation(date, locale, name, width, form, extended);
    };
}
1095897
function (date) {
                if (date instanceof Date === false) {
                    throw new ArgumentError(
                        Logger.logMessage(Logger.LEVEL_SEVERE, "SunPosition", "computeJulianDate", "missingDate"));
                }

                var year = date.getUTCFullYear();
                var month = date.getUTCMonth() + 1;
                var day = date.getUTCDate();
                var hour = date.getUTCHours();
                var minute = date.getUTCMinutes();
                var second = date.getUTCSeconds();

                var dayFraction = (hour + minute / 60 + second / 3600) / 24;

                if (month <= 2) {
                    year -= 1;
                    month += 12;
                }

                var A = Math.floor(year / 100);
                var B = 2 - A + Math.floor(A / 4);
                var JD0h = Math.floor(365.25 * (year + 4716)) + Math.floor(30.6001 * (month + 1)) + day + B - 1524.5;

                return JD0h + dayFraction;
            }
676529
function DateTime(date) {
        if (date instanceof DateTime)
            return date;
        if (_i18n_locale.locale_name == 'en_DEBUG') 
            date = new Date(3333, 10, 22, 11, 22, 33, 123);
        if (date instanceof Date) {
            this.date = date;
            this.hour = date.getHours();
            this.minute = date.getMinutes();
            this.second = date.getSeconds();
            this.microsecond = 0;
            this.year = date.getFullYear();
            this.month = date.getMonth()+1;
            this.day = date.getDate();
        } else {
            for(var k in date) {
                this[k] = date[k];
            }
        }
    }
762029
def to_localized_time(self, date, **kw):
        
        date = api.to_date(date, default=None)
        if date is None:
            return ""
        # default options
        options = {
            "long_format": True,
            "time_only": False,
            "context": self.context,
            "request": self.request,
            "domain": "senaite.core",
        }
        options.update(kw)
        return ulocalized_time(date, **options)
435533
def date_to_string(date, lang = lang)
      local_date_string(date, Localization::DATE_FMT_SHORT[lang], lang)
    end
876415
function getLocaleDayNames(locale, formStyle, width) {
    var /** @type {?} */ data = findLocaleData(locale);
    var /** @type {?} */ daysData = /** @type {?} */ ([data[3 /* DaysFormat */], data[4 /* DaysStandalone */]]);
    var /** @type {?} */ days = getLastDefinedValue(daysData, formStyle);
    return getLastDefinedValue(days, width);
}
1297928
protected Calendar getLocalTimeAsCalendar(BigDecimal localTimeParam, Calendar date) {
        if (localTimeParam == null) {
            return null;
        }

        // Create a clone of the input calendar so we get locale/timezone information.
        Calendar resultTime = (Calendar) date.clone();

        BigDecimal localTime = localTimeParam;
        if (localTime.compareTo(BigDecimal.ZERO) == -1) {
            localTime = localTime.add(BigDecimal.valueOf(24.0D));
            resultTime.add(Calendar.HOUR_OF_DAY, -24);
        }
        String[] timeComponents = localTime.toPlainString().split("\\.");
        int hour = Integer.parseInt(timeComponents[0]);

        BigDecimal minutes = new BigDecimal("0." + timeComponents[1]);
        minutes = minutes.multiply(BigDecimal.valueOf(60)).setScale(0, RoundingMode.HALF_EVEN);
        if (minutes.intValue() == 60) {
            minutes = BigDecimal.ZERO;
            hour += 1;
        }
        if (hour == 24) {
            hour = 0;
        }

        // Set the local time
        resultTime.set(Calendar.HOUR_OF_DAY, hour);
        resultTime.set(Calendar.MINUTE, minutes.intValue());
        resultTime.set(Calendar.SECOND, 0);
        resultTime.set(Calendar.MILLISECOND, 0);
        resultTime.setTimeZone(date.getTimeZone());

        return resultTime;
    }
754182
private String encodeDate(TimeZone browserTZ, TimeZone targetTZ, Date utcDate) {
        return "new Date(" + DateUtils.toLocalDate(browserTZ, targetTZ, utcDate) + ")";
    }
1115312
def _getLocalWhen(self, date_from, num_days=1):
        
        dateFrom, timeFrom = getLocalDateAndTime(date_from, self.time_from,
                                                 self.tz, dt.time.min)
        if num_days > 1 or self.time_to is not None:
            daysDelta = dt.timedelta(days=self.num_days - 1)
            dateTo, timeTo = getLocalDateAndTime(date_from + daysDelta,
                                                 self.time_to, self.tz)
        else:
            dateTo = dateFrom
            timeTo = None

        if dateFrom == dateTo:
            retval = _("{date} {atTime}").format(
                    date=dateFormat(dateFrom),
                    atTime=timeFormat(timeFrom, timeTo, gettext("at ")))
        else:
            # Friday the 10th of April for 3 days at 1pm to 10am
            localNumDays = (dateTo - dateFrom).days + 1
            retval = _("{date} for {n} days {startTime}").format(
                    date=dateFormat(dateFrom),
                    n=localNumDays,
                    startTime=timeFormat(timeFrom, prefix=gettext("starting at ")))
            retval = _("{dateAndStartTime} {finishTime}").format(
                    dateAndStartTime=retval.strip(),
                    finishTime=timeFormat(timeTo, prefix=gettext("finishing at ")))
        return retval.strip()
1023810
function getFuzzyLocalTimeFromPoint(timestamp, point) {
  var tile = tilebelt.pointToTile(point[0], point[1], z).join('/');
  var locale = tiles[tile];

  if (locale) return moment.tz(new Date(timestamp), locale);
  else return undefined;
}