Converts the given date to a localized time string
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)
804862
function getFormattedDate(date, lang, type) {
        date = date || new Date();
        lang = lang || 'en';
        type = type || 'long';

        // set the language for en
        if (lang === 'en' && type === 'short') { lang = 'enshort'; }
        if (lang === 'en' && type === 'medium') { lang = 'enmedium'; }

        // get the date string
        return moment(date).locale(lang).fromNow();
    }
554185
def _time_to_string(self, dt, conversion_string="%Y %m %d %H %M"):
        
        if self.output_timezone is not None:
            dt = dt.replace(tzinfo=utc) \
                   .astimezone(self.output_timezone)
        return dt.strftime(conversion_string)
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];
            }
        }
    }
983141
function parse (dateString, locale, timezone) {
  _checkParams(locale, timezone)
  // list all available localized formats, from most specific to least
  return moment.tz(dateString, [moment.ISO_8601, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], locale, timezone)
}
939372
def strptime(string, timezone=0):
    """"""
    year = int(string[0:4])
    month = int(string[5:7])
    day = int(string[8:10])
    hour = int(string[-5:-3])
    minute = int(string[-2:])
    ts = datetime.datetime(year, month, day) + \
        datetime.timedelta(hours=hour, minutes=minute) - \
        datetime.timedelta(hours=timezone)
    return ts
1206020
def CopyToDateTimeString(self):
    
    if self._number_of_seconds is None:
      return None

    return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:01d}'.format(
        self.year, self.month, self.day_of_month, self.hours, self.minutes,
        self.seconds, self.deciseconds)
142479
def time_from_date(date)
			numbers=date.scan(/\d+/).map!{|i| i.to_i}
			day=numbers[2-numbers.index(numbers.max)]
			Date.new(numbers.max,numbers[1],day).to_time 
		end
1010623
def convert_timezone(obj, timezone):
    
    if timezone is None:
        return obj.replace(tzinfo=None)
    return pytz.timezone(timezone).localize(obj)
222521
def _getFromTime(self, atDate=None):
        
        return getLocalTime(self.date, self.time_from, self.tz)
867551
def to_localtime(time):
    ''''''

    utc_time = time.replace(tzinfo=timezone.utc)
    to_zone = timezone.get_default_timezone()
    return utc_time.astimezone(to_zone)
1268049
def __to_localdatetime(val):
    """"""
    try:
        dt = datetime.strptime(val, __DATE_FORMAT)
        dt = pytz.timezone(__TIMEZONE).localize(dt)
        return dt
    except (ValueError, TypeError):
        return None
435639
def ulocalized_time(self, time, context, request):
        
        value = ut(time, long_format=self.show_time, time_only=False,
                   context=context, request=request)
        return value or ""
996980
def datetime_to_timezone(date, tz="UTC"):
    
    if not date.tzinfo:
        date = date.replace(tzinfo=timezone(get_timezone()))
    return date.astimezone(timezone(tz))
305711
def _getFromTime(self, atDate=None):
        
        return getLocalTime(self.except_date, self.time_from, self.tz)
287860
def _iso8601_to_localized_time(date_string):
    
    parsed_date = datetime.strptime(date_string, '%Y-%m-%dT%H:%M:%S.%fZ')
    localized_time = pytz.utc.localize(parsed_date)
    return localized_time
653701
def to_datetime(value, ctx):
    
    if isinstance(value, str):
        temporal = ctx.get_date_parser().auto(value)
        if temporal is not None:
            return to_datetime(temporal, ctx)
    elif type(value) == datetime.date:
        return ctx.timezone.localize(datetime.datetime.combine(value, datetime.time(0, 0)))
    elif isinstance(value, datetime.datetime):
        return value.astimezone(ctx.timezone)

    raise EvaluationError("Can't convert '%s' to a datetime" % str(value))