Rounds a time value to remove any precision smaller than specified.
@param time the time value to round
@param precision the rounding precision
@param tz the timezone of the rounded value
@return a round time value
507770
public static long round(final long time, final int precision, final TimeZone tz) {
        if ((precision == PRECISION_SECOND) && ((time % Dates.MILLIS_PER_SECOND) == 0)) {
            return time;
        }
        final Calendar cal = Calendar.getInstance(tz);
        cal.setTimeInMillis(time);
        if (precision == PRECISION_DAY) {
//            return (long) Math.floor(time / (double) Dates.MILLIS_PER_DAY) * Dates.MILLIS_PER_DAY;
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.clear(Calendar.MINUTE);
            cal.clear(Calendar.SECOND);
            cal.clear(Calendar.MILLISECOND);
        }
        else if (precision == PRECISION_SECOND) {
//            return (long) Math.floor(time / (double) Dates.MILLIS_PER_SECOND) * Dates.MILLIS_PER_SECOND;
            cal.clear(Calendar.MILLISECOND);
        }
        // unrecognised precision..
        return cal.getTimeInMillis();
    }
1219281
public ZonedDateTime adjustTime(ZonedDateTime time, boolean roundUp,
                                    DayOfWeek firstDayOfWeek) {
        Instant instant = time.toInstant();
        ZoneId zoneId = time.getZone();
        instant = adjustTime(instant, zoneId, roundUp, firstDayOfWeek);
        return ZonedDateTime.ofInstant(instant, zoneId);
    }
327784
private void setTzFormatString(final  TimeZone tz )
    {
        int zIndex = _formatString.indexOf( "ZZZ" );
        if( zIndex >= 0 )
        {
            String ss1 = _formatString.substring( 0, zIndex );
            String ss2 = _formatString.substring( zIndex+3 );
            int tzOffset = tz.getRawOffset();
            
            StringBuffer sb = new StringBuffer(_formatString.length()+10);
            sb.append(ss1);
            sb.append("'");
            if( tzOffset >= 0 )
                sb.append( '+' );
            else
            {
                tzOffset = -tzOffset;
                sb.append( '-' );
            }
            
            int raw = tzOffset / (1000*60);		// Convert to seconds
            int hr = raw / 60;
            int min = raw % 60;
            
            if( hr < 10 )
                sb.append( '0' );
            sb.append( hr );
            if( min < 10 )
                sb.append( '0' );
            sb.append( min );
            sb.append( '\'' );
            
            sb.append(ss2);
            _tzFormatString=sb.toString();            
        }
        else
            _tzFormatString=_formatString;
        setMinFormatString();
    }
858646
public static float round(Float number, int precision) {
        return (float)(Math.floor(number.doubleValue()*Math.pow(10,precision)+0.5)/Math.pow(10,precision));
    }
772392
@Override public void updateTime(final ZonedDateTime TIME) {
        if (dateText.isVisible()) {
            dateText.setText(dateTextFormatter.format(TIME));
            Helper.adjustTextSize(dateText, 0.6 * size, size * 0.08);
            dateText.relocate((size - dateText.getLayoutBounds().getWidth()) * 0.5, size * 0.22180451);
        }
        if (dateNumbers.isVisible()) {
            dateNumbers.setText(dateNumberFormatter.format(TIME));
            Helper.adjustTextSize(dateNumbers, 0.6 * size, size * 0.08);
            dateNumbers.relocate((size -dateNumbers.getLayoutBounds().getWidth()) * 0.5, size * 0.68984962);
        }

        hour.setText(HOUR_FORMATTER.format(TIME));
        Helper.adjustTextSize(hour, 0.4 * size, 0.328 * size);
        hour.relocate(0.136 * size, (size - hour.getLayoutBounds().getHeight()) * 0.5);

        minute.setText(MINUTE_FORMATTER.format(TIME));
        Helper.adjustTextSize(minute, 0.4 * size, 0.328 * size);
        minute.relocate(0.544 * size, (size - minute.getLayoutBounds().getHeight()) * 0.5);

        if (secondBackgroundCircle.isVisible()) {
            secondArc.setLength((-6 * TIME.getSecond()));
            if (clock.isDiscreteSeconds()) {
                secondArc.setLength((-6 * TIME.getSecond()));
            } else {
                secondArc.setLength((-6 * TIME.getSecond() -TIME.get(ChronoField.MILLI_OF_SECOND) * 0.006));
            }
        }
    }
1140282
public static VTimezone convert(List<Daylight> daylights, Timezone tz) {
		UtcOffset tzOffset = ValuedProperty.getValue(tz);
		if (daylights.isEmpty() && tzOffset == null) {
			return null;
		}

		VTimezone timezone = new VTimezone("TZ");
		if (daylights.isEmpty() && tzOffset != null) {
			StandardTime st = new StandardTime();
			st.setTimezoneOffsetFrom(tzOffset);
			st.setTimezoneOffsetTo(tzOffset);
			timezone.addStandardTime(st);
			return timezone;
		}

		for (Daylight daylight : daylights) {
			if (!daylight.isDaylight()) {
				continue;
			}

			UtcOffset daylightOffset = daylight.getOffset();
			UtcOffset standardOffset = new UtcOffset(daylightOffset.getMillis() - (1000 * 60 * 60));

			DaylightSavingsTime dst = new DaylightSavingsTime();
			dst.setDateStart(daylight.getStart());
			dst.setTimezoneOffsetFrom(standardOffset);
			dst.setTimezoneOffsetTo(daylightOffset);
			dst.addTimezoneName(daylight.getDaylightName());
			timezone.addDaylightSavingsTime(dst);

			StandardTime st = new StandardTime();
			st.setDateStart(daylight.getEnd());
			st.setTimezoneOffsetFrom(daylightOffset);
			st.setTimezoneOffsetTo(standardOffset);
			st.addTimezoneName(daylight.getStandardName());
			timezone.addStandardTime(st);
		}

		return timezone.getComponents().isEmpty() ? null : timezone;
	}
161134
public static ZonedDateTime convertToZonedDateTime(final String value) {
        val dt = DateTimeUtils.zonedDateTimeOf(value);
        if (dt != null) {
            return dt;
        }
        val lt = DateTimeUtils.localDateTimeOf(value);
        return DateTimeUtils.zonedDateTimeOf(lt.atZone(ZoneOffset.UTC));
    }
780348
def RoundToSeconds(cls, timestamp):
    """"""
    leftovers = timestamp % definitions.MICROSECONDS_PER_SECOND
    scrubbed = timestamp - leftovers
    rounded = round(float(leftovers) / definitions.MICROSECONDS_PER_SECOND)

    return int(scrubbed + rounded * definitions.MICROSECONDS_PER_SECOND)
370305
public function time($time, $precision = 0)
    {
        $units = 's';
        if ($time < 1e-6) {    // <1us
            $units = 'ns';
            $time *= 1e9;

        } elseif ($time < 1e-3) { // <1ms
            $units = "\xc2\xb5s";
            $time *= 1e6;

        } elseif ($time < 1) { // <1s
            $units = 'ms';
            $time *= 1e3;
        }

        return \round($time, $precision) . ' ' . $units;
    }
408343
def round(ndigits = 0)
      if_timezone_offset(super) {|o,t| self.class.at(t.to_i, t.subsec * 1_000_000).set_timezone_offset(o) }
    end
824373
private static function _createDateTime($time = null, $tz = null): \DateTimeImmutable
    {
        if (!isset($time)) {
            $time = 'now';
        }
        if (!isset($tz)) {
            $tz = date_default_timezone_get();
        }
        try {
            $dt = new \DateTimeImmutable($time, self::_createTimeZone($tz));
            return self::_roundDownFractionalSeconds($dt);
        } catch (\Exception $e) {
            throw new \RuntimeException(
                "Failed to create DateTime: " .
                     self::_getLastDateTimeImmutableErrorsStr(), 0, $e);
        }
    }
1187858
public static final Date utc2date(Long time) {

        // don't accept negative values
        if (time == null || time < 0) return null;
        
        // add the timezone offset
        time += timezoneOffsetMillis(new Date(time));

        return new Date(time);
    }
466620
def elapse_time(start, end=None, precision=3):
    
    if end is None:
        end = time_module.time()
    return round(end-start, precision)
1374319
public final void setTimeZone(final TimeZone timeZone) {
        if (!Value.DATE.equals(type)) {
            for (Date date: this) {
                ((DateTime) date).setTimeZone(timeZone);
            }
        }
        this.timeZone = timeZone;
        this.utc = false;
    }
1294246
def ensure_utc(time, tz='UTC'):
    
    if not time.tzinfo:
        time = time.replace(tzinfo=pytz.timezone(tz))
    return time.replace(tzinfo=pytz.utc)
7344
public static long roundToDay(final long pTime, final TimeZone pTimeZone) {
        int offset = pTimeZone.getOffset(pTime);
        return (((pTime  + offset) / DAY) * DAY) - offset;
    }
98382
public function getFormattedTime(
        $time,
        $precision = 0,
        $floatingPrecision = 3,
        $showUnit = true
    ) {

        $test = is_int(
                $precision
            ) && $precision >= 0 && $precision <= 2 &&
            is_float($time) &&
            is_int($floatingPrecision) && $floatingPrecision >= 0 &&
            is_bool($showUnit);

        if ($test) {
            $duration = round($time * 10 * ($precision * 3), $floatingPrecision);

            if ($showUnit) {
                switch ($precision) {
                    case 0 :
                        return $duration . ' s';
                    case 1 :
                        return $duration . ' ms';
                    case 2 :
                        return $duration . ' µs';
                    default :
                        return $duration . ' (no unit)';
                }
            } else {
                return $duration;
            }
        } else {
            return 'Can\'t return the render time';
        }
    }