/*[deutsch]
<p>Allgemeine Konversionsmethode. </p>

@param   ut      UNIX-timestamp
@return  corresponding {@code Moment}
354047
public static Moment from(UnixTime ut) {

        if (ut instanceof Moment) {
            return (Moment) ut;
        } else if (
            (ut instanceof UniversalTime)
            && LeapSeconds.getInstance().isEnabled()
        ) {
            UniversalTime utc = UniversalTime.class.cast(ut);
            return Moment.of(
                utc.getElapsedTime(UTC),
                utc.getNanosecond(UTC),
                UTC);
        } else {
            return Moment.of(
                ut.getPosixTime(),
                ut.getNanosecond(),
                POSIX);
        }

    }
1294561
@Deprecated
    public TimeUnitFormat setLocale(ULocale locale) {
        if (locale != this.locale){
            mf = mf.withLocale(locale);

            // Needed for getLocale(ULocale.VALID_LOCALE)
            setLocale(locale, locale);
            this.locale = locale;
            isReady = false;
        }
        return this;
    }
107042
public static ApiVersion getMythVersion(String baseUri, long connectTimeout, TimeUnit timeUnit) throws IOException {
        OkHttpClient client = new OkHttpClient();
        client.setConnectTimeout(connectTimeout, timeUnit);
        return getMythVersion(baseUri, client);
    }
593283
@Override
    protected Moment doConnect() throws IOException, ParseException {

        final NetTimeConfiguration cfg = this.getNetTimeConfiguration();

        URL url = new URL(cfg.getTimeServerAddress());
        int timeoutMillis =
            MathUtils.safeMultiply(cfg.getConnectionTimeout(), 1000);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setConnectTimeout(timeoutMillis);
        conn.setReadTimeout(timeoutMillis);
        conn.setUseCaches(false);
        conn.setRequestMethod("HEAD");

        int responseCode = conn.getResponseCode();

        if (responseCode >= 200 && responseCode <= 399) {
            return JAVA_UTIL_DATE.translate(new Date(conn.getDate()));
        }

        throw new IOException("HTTP server status: " + responseCode);

    }
582191
static Generator byMinuteGenerator(
            int[] minutes, final DateValue dtStart) {
        minutes = Util.uniquify(minutes);
        if (minutes.length == 0) {
            minutes = new int[]{
                    dtStart instanceof TimeValue ? ((TimeValue) dtStart).minute() : 0
            };
        }
        final int[] uminutes = minutes;

        if (uminutes.length == 1) {
            final int minute = uminutes[0];

            return new SingleValueGenerator() {
                int year;
                int month;
                int day;
                int hour;

                @Override
                boolean generate(DTBuilder builder) {
                    if ((year != builder.year) || (month != builder.month)
                            || (day != builder.day) || (hour != builder.hour)) {
                        year = builder.year;
                        month = builder.month;
                        day = builder.day;
                        hour = builder.hour;
                        builder.minute = minute;
                        return true;
                    }
                    return false;
                }

                @Override
                int getValue() {
                    return minute;
                }

                @Override
                public String toString() {
                    return "byMinuteGenerator:" + minute;
                }
            };
        }

        return new Generator() {
            int i;
            int year = dtStart.year();
            int month = dtStart.month();
            int day = dtStart.day();
            int hour = dtStart instanceof TimeValue
                    ? ((TimeValue) dtStart).hour() : 0;

            {
                int minute = dtStart instanceof TimeValue
                        ? ((TimeValue) dtStart).minute() : 0;
                while (i < uminutes.length && uminutes[i] < minute) {
                    ++i;
                }
            }

            @Override
            boolean generate(DTBuilder builder) {
                if ((year != builder.year) || (month != builder.month)
                        || (day != builder.day) || (hour != builder.hour)) {
                    i = 0;
                    year = builder.year;
                    month = builder.month;
                    day = builder.day;
                    hour = builder.hour;
                }
                if (i >= uminutes.length) {
                    return false;
                }
                builder.minute = uminutes[i++];
                return true;
            }

            @Override
            public String toString() {
                return "byMinuteGenerator:" + Arrays.toString(uminutes);
            }
        };
    }
1053608
function Moment(config, skipOverflow) {
        if (skipOverflow !== false) {
            checkOverflow(config);
        }
        copyConfig(this, config);
        this._d = new Date(+config._d);
        // Prevent infinite loop in case updateOffset creates new moment
        // objects.
        if (updateInProgress === false) {
            updateInProgress = true;
            moment.updateOffset(this);
            updateInProgress = false;
        }
    }
940331
function momentParse( str, formats, options ) {
   const origParseTwoDigitYear = moment.parseTwoDigitYear;
   if( options.dateTwoDigitYearWrap > -1 && options.dateTwoDigitYearWrap < 100 ) {
      moment.parseTwoDigitYear = input => {
         let int = parseInt( input, 10 );
         int = isNaN( int ) ? 0 : int;
         return int + ( int > options.dateTwoDigitYearWrap ? 1900 : 2000 );
      };
   }

   try {
      return moment( str, formats, true );
   }
   finally {
      moment.parseTwoDigitYear = origParseTwoDigitYear;
   }
}
694219
public final void setUtc(final boolean utc) {
        if (!Value.DATE.equals(type)) {
            for (Date date: this) {
                ((DateTime) date).setUtc(utc);
            }
        }
        this.timeZone = null;
        this.utc = utc;
    }
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;
}
844626
public static Timestamp toSqlTimestamp(Instant instant) {
        try {
            Timestamp ts = new Timestamp(instant.getEpochSecond() * 1000);
            ts.setNanos(instant.getNano());
            return ts;
        } catch (ArithmeticException ex) {
            throw new IllegalArgumentException(ex);
        }
    }
1161706
public static long generateDatumTime(long initializeTime, TimeUnit unit) throws ParseException
    {
        // 初期に生成するファイル名称を基準となる値にするため、ファイル切替インターバル（単位）より１つ大きな単位を取得し
        // １つ大きな単位をベースに時刻を算出する。
        // 例：10分間隔であれば「0.10.20....」というのが基準となる値。
        SimpleDateFormat parentDateFormat = new SimpleDateFormat(
                TimeUnitUtil.getDatePattern(TimeUnitUtil.getParentUnit(unit)));

        // １つ大きな単位をベースに基準時刻を取得し、初期生成ファイル名称用の日時を算出する。
        // 例：10分間隔をインターバルとし、8:35を起動時刻とした場合、8:00を基準時刻とする。
        String datumTimeString = parentDateFormat.format(new Date(initializeTime));

        long datumTime = parentDateFormat.parse(datumTimeString).getTime();
        return datumTime;
    }
816897
@SafeVarargs
    public static <T extends ChronoEntity<T>> MultiFormatParser<T> of(ChronoFormatter<T>... formats) {

        ChronoFormatter<T>[] parsers = Arrays.copyOf(formats, formats.length);
        return new MultiFormatParser<>(parsers);

    }
293204
public Timestamp parse(String source, ParsePosition pos) {
        if (nanoPattern)
            throw new UnsupportedOperationException("Not supporting parsing of nanosecond field.");
        return Timestamp.of(dateFormat.parse(source, pos));
    }
167372
function fixFormat(format, _moment) {
    var i = 5;
    var replace = function (input) {
        return _moment.localeData().longDateFormat(input) || input;
    };
    while (i > 0 && localFormattingTokens.test(format)) {
        i -= 1;
        format = format.replace(localFormattingTokens, replace);
    }
    return format;
}
222242
public Date getUTCTime(int len) throws IOException {
        if (len > available())
            throw new IOException("short read of DER UTC Time");

        if (len < 11 || len > 17)
            throw new IOException("DER UTC Time length error");

        return getTime(len, false);
    }
1186349
public static Matcher<Date> hasHourMinAndSec(final int hour, final int minute, final int second) {
        return new IsDateWithTime(hour, minute, second, null);
    }
159524
@XmlElementDecl(namespace = "http://www.w3.org/1998/Math/MathML", name = "moment")
    public JAXBElement<MomentType> createMoment(MomentType value) {
        return new JAXBElement<MomentType>(_Moment_QNAME, MomentType.class, null, value);
    }