001/**
002 * Java Web Archive Toolkit - Software to read and validate ARC, WARC
003 * and GZip files. (http://jwat.org/)
004 * Copyright 2011-2012 Netarkivet.dk (http://netarkivet.dk/)
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jwat.warc;
019
020import java.time.LocalDateTime;
021import java.time.ZoneId;
022import java.util.Date;
023import java.util.Objects;
024import java.util.TimeZone;
025
026import org.jwat.common.Numbers;
027
028/**
029 * Separate class to handle WARC dates now that they can have varying precision levels.
030 * Also useful now that the <code>Date</code> class has been deprecated.
031 * This class maintains the UTC date time internally along with other fields.
032 * The old implementation just used the <code>Date</code> object directly leaving the timezone mess to the user.
033 *
034 * Please note the following:
035 * JDK8 precision is millis. JDK9+ is nano precision.
036 * Converting from DateTime to Date on JDK9+ will therefore give precision errors unless compensated for.
037 *
038 * Exampples:
039 *
040 * WARC-Date: 2016-01-11T23:24:25.412030Z
041 * WARC-Date: 2016-01-11T23:24:25Z
042 * WARC-Date: 2016-01
043 * Year:
044 * YYYY (eg 1997)
045 * Year and month:
046 * YYYY-MM (eg 1997-07)
047 * Complete date:
048 * YYYY-MM-DD (eg 1997-07-16)
049 * Complete date plus hours and minutes:
050 * YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
051 * Complete date plus hours, minutes and seconds:
052 * YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
053 * Complete date plus hours, minutes, seconds and a decimal fraction of a second
054 * YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
055 *
056 * @author nicl
057 */
058public class WarcDate {
059
060    /** UTC <code>TimeZone</code> object for reuse. */
061    protected static TimeZone UTC_TIMEZONE = TimeZone.getTimeZone("UTC");
062
063    /** internal array used to convert digit to char. */
064    protected static int[] asciiInt;
065
066    /*
067     * Initialize the digit to char array.
068     */
069    static {
070        asciiInt = new int[256];
071        for (int i=0; i<256; ++i) {
072            asciiInt[i] = -1;
073        }
074        asciiInt['0'] = 0;
075        asciiInt['1'] = 1;
076        asciiInt['2'] = 2;
077        asciiInt['3'] = 3;
078        asciiInt['4'] = 4;
079        asciiInt['5'] = 5;
080        asciiInt['6'] = 6;
081        asciiInt['7'] = 7;
082        asciiInt['8'] = 8;
083        asciiInt['9'] = 9;
084    }
085
086    /** Year level precision. */
087    public static final int P_YEAR = 0;
088    /** Month level precision. */
089    public static final int P_MONTH = 1;
090    /** Day of month level precision. */
091    public static final int P_DAYOFMONTH = 2;
092    /** Minute level precision. */
093    public static final int P_MINUTE = 3;
094    /** Second level precision. */
095    public static final int P_SECOND = 4;
096    /** Nano/fraction level precision. */
097    public static final int P_FRACTION = 5;
098
099    /** Object used to convert dates, handle timezones and retrieve fields. */
100    public LocalDateTime ldt;
101
102    /** Precision level of the warc date (year to fraction). */
103    public int precision;
104
105    /** Year. */
106    public int year;
107    /** Month (1-12). */
108    public int month;
109    /** Day of month (1-31). */
110    public int dayOfMonth;
111    /** Hour (0-23). */
112    public int hour;
113    /** Minute (0-59). */
114    public int minute;
115    /** Second (0-59). */
116    public int second;
117    /** Nano of second (0-999.999.999).*/
118    public int nanoOfSecond;
119    /** Bigger fraction in case someone needs more than nano precision. */
120    public long fraction;
121    /** Length of the fraction string representation. */
122    public int fractionLen;
123
124    /**
125     * Construct <code>WarcDate</code> with year level precision.
126     * @param year year
127     */
128    public WarcDate(int year) {
129        precision = P_YEAR;
130        this.ldt = LocalDateTime.of(year, 1, 1, 0, 0);
131        this.year = year;
132    }
133
134    /**
135     * Construct <code>WarcDate</code> with month level precision.
136     * @param year year
137     * @param month integer between 1 and 12
138     */
139    public WarcDate(int year, int month) {
140        precision = P_MONTH;
141        this.ldt = LocalDateTime.of(year, month, 1, 0, 0);
142        this.year = year;
143        this.month = month;
144    }
145
146    /**
147     * Create <code>WarcDate</code> with day of month level precision.
148     * @param year year
149     * @param month integer between 1 and 12
150     * @param dayOfMonth integer between 1 and 31
151     */
152    public WarcDate(int year, int month, int dayOfMonth) {
153        precision = P_DAYOFMONTH;
154        this.ldt = LocalDateTime.of(year, month, dayOfMonth, 0, 0);
155        this.year = year;
156        this.month = month;
157        this.dayOfMonth = dayOfMonth;
158    }
159
160    /**
161     * Create <code>WarcDate</code> with minute level precision.
162     * @param year year
163     * @param month integer between 1 and 12
164     * @param dayOfMonth integer between 1 and 31
165     * @param hour integer between 0 and 59
166     * @param minute integer between 0 and 59
167     */
168    public WarcDate(int year, int month, int dayOfMonth, int hour, int minute) {
169        precision = P_MINUTE;
170        this.ldt = LocalDateTime.of(year, month, dayOfMonth, hour, minute);
171        this.year = year;
172        this.month = month;
173        this.dayOfMonth = dayOfMonth;
174        this.hour = hour;
175        this.minute = minute;
176    }
177
178    /**
179     * Create <code>WarcDate</code> with second level precision.
180     * @param year year
181     * @param month integer between 1 and 12
182     * @param dayOfMonth integer between 1 and 31
183     * @param hour integer between 0 and 59
184     * @param minute integer between 0 and 59
185     * @param second integer between 0 and 59
186     */
187    public WarcDate(int year, int month, int dayOfMonth, int hour, int minute, int second) {
188        precision = P_SECOND;
189        this.ldt = LocalDateTime.of(year, month, dayOfMonth, hour, minute, second);
190        this.year = year;
191        this.month = month;
192        this.dayOfMonth = dayOfMonth;
193        this.hour = hour;
194        this.minute = minute;
195        this.second = second;
196    }
197
198    /**
199     * Create <code>WarcDate</code> with nano if second level precision.
200     * Nano of second is used with the internal <code>LocalDateTime</code> object.
201     * @param year year
202     * @param month integer between 1 and 12
203     * @param dayOfMonth integer between 1 and 31
204     * @param hour integer between 0 and 59
205     * @param minute integer between 0 and 59
206     * @param second integer between 0 and 59
207     * @param nanoOfSecond integer between 0 and 999.999.999.
208     */
209    public WarcDate(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond) {
210        precision = P_FRACTION;
211        this.ldt = LocalDateTime.of(year, month, dayOfMonth, hour, minute, second, nanoOfSecond);
212        this.year = year;
213        this.month = month;
214        this.dayOfMonth = dayOfMonth;
215        this.hour = hour;
216        this.minute = minute;
217        this.second = second;
218        this.nanoOfSecond = nanoOfSecond;
219        this.fraction = nanoOfSecond;
220        if (nanoOfSecond == 0) {
221            this.fractionLen = 1;
222        }
223        else {
224            this.fractionLen = 9;
225            int trailingZeros = Numbers.intTrailingZeros(nanoOfSecond);
226            while (trailingZeros > 0) {
227                fraction = fraction / 10;
228                --fractionLen;
229                --trailingZeros;
230            }
231        }
232    }
233
234    /**
235     * Create <code>WarcDate</code> with nano if second level precision.
236     * Nano of second is used with the internal <code>LocalDateTime</code> object.
237     * Even though nano of second is currently the limit in Java this implementation can
238     * parse, store and ouput the fraction part as an long value.
239     * @param year year
240     * @param month integer between 1 and 12
241     * @param dayOfMonth integer between 1 and 31
242     * @param hour integer between 0 and 59
243     * @param minute integer between 0 and 59
244     * @param second integer between 0 and 59
245     * @param nanoOfSecond integer between 0 and 999999999.
246     * @param fraction long fraction between 0 and 9223372036854775807.
247     * @param fractionLen franction length to output when converting to a string representation
248     */
249    public WarcDate(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond, long fraction, int fractionLen) {
250        precision = P_FRACTION;
251        this.ldt = LocalDateTime.of(year, month, dayOfMonth, hour, minute, second, nanoOfSecond);
252        this.year = year;
253        this.month = month;
254        this.dayOfMonth = dayOfMonth;
255        this.hour = hour;
256        this.minute = minute;
257        this.second = second;
258        this.nanoOfSecond = nanoOfSecond;
259        this.fraction = fraction;
260        this.fractionLen = fractionLen;
261    }
262
263    /**
264     * Create <code>WarcDate</code> with nano if second level precision.
265     * Nano of second is used with the internal <code>LocalDateTime</code> object.
266     * Do not reuse the <code>LocalDateTime</code> instance!
267     * Nano of second is used with the internal <code>LocalDateTime</code> object.
268     * @param ldt keep this object internally and use it values
269     */
270    public WarcDate(LocalDateTime ldt) {
271        precision = P_FRACTION;
272        this.ldt = ldt;
273        this.year = ldt.getYear();
274        this.month = ldt.getMonthValue();
275        this.dayOfMonth = ldt.getDayOfMonth();
276        this.hour = ldt.getHour();
277        this.minute = ldt.getMinute();
278        this.second = ldt.getSecond();
279        this.nanoOfSecond = ldt.getNano();
280        this.fraction = nanoOfSecond;
281        this.fractionLen = 9;
282    }
283
284    /**
285     * Returns a <code>WarcDate</code> representing the current UTC date time.
286     * @return a <code>WarcDate</code> representing the current UTC date time
287     */
288    public static WarcDate now() {
289        return new WarcDate(LocalDateTime.now(UTC_TIMEZONE.toZoneId()));
290    }
291
292    /**
293     * Returns a <code>WarcDate</code> object from on a <code>Date</code> in the default system timezone.
294     * @param date date in the system default timezone (technically deprecated)
295     * @return <code>WarcDate</code> object
296     */
297    public static WarcDate fromLocalDate(Date date) {
298        // Date adjusted from system default timezone to UTC timezone.
299        return new WarcDate(LocalDateTime.ofInstant(date.toInstant(), UTC_TIMEZONE.toZoneId()));
300    }
301
302    /**
303     * Returns a <code>Date</code> representing the internal date time adjusted to the system default timezone.
304     * @return a <code>Date</code> representing the internal date time adjusted to the system default timezone
305     */
306    public Date getDateLocal() {
307        // Date adjusted from UTZ timezone to system default timezone.
308        // Meaning it is the local date time.
309        return Date.from((ldt.atZone(UTC_TIMEZONE.toZoneId()).toInstant()));
310    }
311
312    /**
313     * Returns a <code>WarcDate</code> object from on a <code>Date</code> in the default system timezone.
314     * @param date date in the system default timezone (technically deprecated)
315     * @return <code>WarcDate</code> object
316     */
317    public static WarcDate fromUTCDate(Date date) {
318        // Date adjusted from system default timezone to system default timezone.
319        // Meaning it is left as is, UTC timezone date expected.
320        return new WarcDate(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()));
321    }
322
323    /**
324     * Returns a <code>Date</code> representing the internal date time (UTC timezone).
325     * @return a <code>Date</code> representing the internal date time (UTC timezone)
326     */
327    public Date getDateUTC() {
328        // Date adjusted from system default timezone to system default timezone.
329        // Meaning it is left as is, which should be UTC.
330        return Date.from((ldt.atZone(ZoneId.systemDefault()).toInstant()));
331    }
332
333    /**
334     * Attempt to parse a WARC date string in a subset of the W3CDTF format.
335     * @param datestring WARC date string
336     * @return <code>WarcDate</code> object
337     */
338    public static WarcDate getWarcDate(String datestring) {
339        byte[] bytes = datestring.getBytes();
340        return getWarcDate(bytes, 0, bytes.length);
341    }
342
343    /**
344     * Attempt to parse a WARC date string from a byte array in a subset of the W3CDTF format.
345     * @param bytes WARC date string as a byte array
346     * @param pos start position in the byte array
347     * @param limit limit in the byte array
348     * @return <code>WarcDate</code> object
349     */
350    public static WarcDate getWarcDate(byte[] bytes, int pos, int limit) {
351        //TimeZone timeZone = TimeZone.getTimeZone("UTC");
352        //Calendar calendar = Calendar.getInstance(timeZone);
353        int idx = pos;
354        int len = limit - pos;
355        int c;
356        int chr;
357        int chr2;
358        int year;
359        int month;
360        int dayOfMonth;
361        int hour;
362        int minute;
363        int second;
364        int ie;
365        int ie2;
366        int nanoOfSecond;
367        int nanoStrLen;
368        long fraction;
369        int fractionStrLen;
370        long le;
371        if (len >= 4) {
372            // Year
373            year = asciiInt[bytes[idx++] & 255];
374            ie = year;
375            c = asciiInt[bytes[idx++] & 255];
376            ie |= c;
377            year = (year << 3) + (year << 1) + c;
378            c = asciiInt[bytes[idx++] & 255];
379            ie |= c;
380            year = (year << 3) + (year << 1) + c;
381            c = asciiInt[bytes[idx++] & 255];
382            ie |= c;
383            year = (year << 3) + (year << 1) + c;
384            if (ie < 0) {
385                return null;
386            }
387            if (len == 4) {
388                return new WarcDate(year);
389            }
390            if (len >= 7) {
391                // Month
392                chr = bytes[idx++] & 255;
393                month = asciiInt[bytes[idx++] & 255];
394                ie = month;
395                c = asciiInt[bytes[idx++] & 255];
396                ie |= c;
397                month = (month << 3) + (month << 1) + c;
398                if (ie < 0 || '-' != chr) {
399                    return null;
400                }
401                if (len == 7) {
402                    return new WarcDate(year, month);
403                }
404                if (len >= 10) {
405                    // Date
406                    chr = bytes[idx++] & 255;
407                    dayOfMonth = asciiInt[bytes[idx++] & 255];
408                    ie = dayOfMonth;
409                    c = asciiInt[bytes[idx++] & 255];
410                    ie |= c;
411                    dayOfMonth = (dayOfMonth << 3) + (dayOfMonth << 1) + c;
412                    if (ie < 0 || '-' != chr) {
413                        return null;
414                    }
415                    if (len == 10) {
416                        return new WarcDate(year, month, dayOfMonth);
417                    }
418                    if (len >= 16) {
419                        // 'T' hour and minute.
420                        chr = bytes[idx++] & 255;
421                        hour = asciiInt[bytes[idx++] & 255];
422                        ie = hour;
423                        c = asciiInt[bytes[idx++] & 255];
424                        ie |= c;
425                        hour = (hour << 3) + (hour << 1) + c;
426                        chr2 = bytes[idx++] & 255;
427                        minute = asciiInt[bytes[idx++] & 255];
428                        ie2 = minute;
429                        c = asciiInt[bytes[idx++] & 255];
430                        ie2 |= c;
431                        minute = (minute << 3) + (minute << 1) + c;
432                        if (ie < 0 || ie2 < 0 || ('T' != chr && 't' != chr) || ':' != chr2) {
433                            return null;
434                        }
435                        if (len == 17) {
436                            chr = (bytes[idx++] & 255);
437                            if ('Z' != chr && 'z' != chr) {
438                                return null;
439                            }
440                            else {
441                                return new WarcDate(year, month, dayOfMonth, hour, minute);
442                            }
443                        }
444                        if (len >= 19) {
445                            // Second.
446                            chr = bytes[idx++] & 255;
447                            second = asciiInt[bytes[idx++] & 255];
448                            ie = second;
449                            c = asciiInt[bytes[idx++] & 255];
450                            ie |= c;
451                            second = (second << 3) + (second << 1) + c;
452                            if (ie < 0 || ':' != chr) {
453                                return null;
454                            }
455                            if (len == 20) {
456                                chr = (bytes[idx++] & 255);
457                                if ('Z' != chr && 'z' != chr) {
458                                    return null;
459                                }
460                                else {
461                                    return new WarcDate(year, month, dayOfMonth, hour, minute, second);
462                                }
463                            }
464                            if (len >= 22) {
465                                // '.' Fraction.
466                                chr = bytes[idx++] & 255;
467                                fraction = 0;
468                                fractionStrLen = 0;
469                                le = 0;
470                                while (idx < len - 1 && fractionStrLen < 9) {
471                                    c = asciiInt[bytes[idx++] & 255];
472                                    le |= c;
473                                    fraction = (fraction << 3) + (fraction << 1) + c;
474                                    ++fractionStrLen;
475                                }
476                                nanoOfSecond = (int)fraction;
477                                nanoStrLen = fractionStrLen;
478                                while (idx < len - 1) {
479                                    c = asciiInt[bytes[idx++] & 255];
480                                    le |= c;
481                                    fraction = (fraction << 3) + (fraction << 1) + c;
482                                    ++fractionStrLen;
483                                }
484                                while (nanoStrLen < 9) {
485                                    nanoOfSecond = (nanoOfSecond << 3) + (nanoOfSecond << 1);
486                                    ++nanoStrLen;
487                                }
488                                chr = (bytes[idx++] & 255);
489                                if (le < 0 || ('Z' != chr && 'z' != chr)) {
490                                    return null;
491                                }
492                                else {
493                                    return new WarcDate(year, month, dayOfMonth, hour, minute, second, nanoOfSecond, fraction, fractionStrLen);
494                                }
495                            }
496                        }
497                    }
498                }
499            }
500        }
501        return null;
502    }
503
504    /**
505     * Adjust internal state to millisecond precision.
506     * Mostly for debugging purposes since converting from DateTime to Date
507     * and back to Date loses fraction precision beyond milliseconds.
508     * JDK8 precision is millis. JDK9+ is nano precision.
509     * This method is for those occasions when you run into problems.
510     */
511    public void trimToMillis() {
512        int trimDigits;
513        if (nanoOfSecond != 0) {
514            nanoOfSecond = nanoOfSecond - (nanoOfSecond % 1000000);
515            ldt = ldt.withNano(nanoOfSecond);
516        }
517        if (fraction != 0) {
518            trimDigits = fractionLen - 3;
519            if (trimDigits > 0) {
520                fraction = Numbers.longModulo(fraction, trimDigits);
521            }
522        }
523    }
524
525    /**
526     * Adjust the precision and initialize the appropriate fields.
527     * @param newPrecision the new precision
528     */
529    public void adjustPrecisionTo(int newPrecision) {
530        if (newPrecision > precision) {
531            switch (precision) {
532            case P_FRACTION:
533            case P_SECOND:
534            case P_MINUTE:
535            case P_DAYOFMONTH:
536                if (dayOfMonth == 0) {
537                    dayOfMonth = 1;
538                }
539            case P_MONTH:
540                if (month == 0) {
541                    month = 1;
542                }
543            case P_YEAR:
544            default:
545                break;
546            }
547        }
548        precision = newPrecision;
549    }
550
551    @Override
552    public String toString() {
553        char[] tmpStr = null;
554        int fractionIdx;
555        int tmpFractionLen;
556        long tmpFraction;
557        switch (precision) {
558        case P_YEAR:
559            tmpStr = new char[4];
560            break;
561        case P_MONTH:
562            tmpStr = new char[7];
563            break;
564        case P_DAYOFMONTH:
565            tmpStr = new char[10];
566            break;
567        case P_MINUTE:
568            tmpStr = new char[17];
569            break;
570        case P_SECOND:
571            tmpStr = new char[20];
572            break;
573        case P_FRACTION:
574            tmpStr = new char[21 + fractionLen];
575            break;
576        default:
577            throw new IllegalStateException("Invalid precision level.");
578        }
579        int idx = 0;
580        if (precision >= P_YEAR) {
581            tmpStr[idx++] = (char)('0' + year / 1000 % 10);
582            tmpStr[idx++] = (char)('0' + year / 100 % 10);
583            tmpStr[idx++] = (char)('0' + year / 10 % 10);
584            tmpStr[idx++] = (char)('0' + year % 10);
585            if (precision >= P_MONTH) {
586                tmpStr[idx++] = '-';
587                tmpStr[idx++] = (char)('0' + month / 10 % 10);
588                tmpStr[idx++] = (char)('0' + month % 10);
589                if (precision >= P_DAYOFMONTH) {
590                    tmpStr[idx++] = '-';
591                    tmpStr[idx++] = (char)('0' + dayOfMonth / 10 % 10);
592                    tmpStr[idx++] = (char)('0' + dayOfMonth % 10);
593                    if (precision >= P_MINUTE) {
594                        tmpStr[idx++] = 'T';
595                        tmpStr[idx++] = (char)('0' + hour / 10 % 10);
596                        tmpStr[idx++] = (char)('0' + hour % 10);
597                        tmpStr[idx++] = ':';
598                        tmpStr[idx++] = (char)('0' + minute / 10 % 10);
599                        tmpStr[idx++] = (char)('0' + minute % 10);
600                        if (precision >= P_SECOND) {
601                            tmpStr[idx++] = ':';
602                            tmpStr[idx++] = (char)('0' + second / 10 % 10);
603                            tmpStr[idx++] = (char)('0' + second % 10);
604                            if (precision >= P_FRACTION) {
605                                tmpStr[idx++] = '.';
606                                tmpFraction = fraction;
607                                tmpFractionLen = fractionLen;
608                                idx += fractionLen;
609                                fractionIdx = idx;
610                                tmpStr[--fractionIdx] = (char)('0' + tmpFraction % 10);
611                                --tmpFractionLen;
612                                while (tmpFractionLen > 0) {
613                                    tmpFraction = tmpFraction / 10;
614                                    tmpStr[--fractionIdx] = (char)('0' + tmpFraction % 10);
615                                    --tmpFractionLen;
616                                }
617                            }
618                        }
619                        tmpStr[idx++] = 'Z';
620                    }
621                }
622            }
623        }
624        return new String(tmpStr);
625    }
626
627    /**
628     * For debugging purposes you can get a string of the internal fields and their values.
629     * @return the internal represented in string form
630     */
631    public String debugString() {
632        StringBuilder sb = new StringBuilder();
633        sb.append("precision: ");
634        sb.append(precision);
635        sb.append(" - ");
636        sb.append("year: ");
637        sb.append(year);
638        sb.append(" - ");
639        sb.append("month: ");
640        sb.append(month);
641        sb.append(" - ");
642        sb.append("dayOfMonth: ");
643        sb.append(dayOfMonth);
644        sb.append(" - ");
645        sb.append("hour: ");
646        sb.append(hour);
647        sb.append(" - ");
648        sb.append("minute: ");
649        sb.append(minute);
650        sb.append(" - ");
651        sb.append("second: ");
652        sb.append(second);
653        sb.append(" - ");
654        sb.append("nanoOfSecond: ");
655        sb.append(nanoOfSecond);
656        sb.append(" - ");
657        sb.append("fraction: ");
658        sb.append(fraction);
659        sb.append(" - ");
660        sb.append("fractionLen: ");
661        sb.append(fractionLen);
662        sb.append(" - ");
663        sb.append("ldt: ");
664        sb.append(ldt.toString());
665        return sb.toString();
666    }
667
668    @Override
669    public int hashCode() {
670        return Objects.hash(dayOfMonth, fraction, fractionLen, hour, ldt, minute, month, nanoOfSecond, precision, second, year);
671    }
672
673    @Override
674    public boolean equals(Object obj) {
675        if (this == obj)
676            return true;
677        if (obj == null)
678            return false;
679        if (getClass() != obj.getClass())
680            return false;
681        WarcDate other = (WarcDate) obj;
682        return dayOfMonth == other.dayOfMonth && fraction == other.fraction && fractionLen == other.fractionLen
683                && hour == other.hour && Objects.equals(ldt, other.ldt) && minute == other.minute
684                && month == other.month && nanoOfSecond == other.nanoOfSecond && precision == other.precision
685                && second == other.second && year == other.year;
686    }
687
688}