@fr0st/datetime 5.1.5 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1001 -103
- package/dist/frost-datetime.js +1243 -433
- package/dist/frost-datetime.js.map +1 -1
- package/dist/frost-datetime.min.js +1 -1
- package/dist/frost-datetime.min.js.map +1 -1
- package/package.json +7 -7
- package/src/formatter/format.js +18 -1
- package/src/helpers.js +113 -57
- package/src/index.js +103 -6
- package/src/prototype/attributes-get.js +1 -1
- package/src/prototype/comparisons.js +605 -0
- package/src/prototype/manipulate.js +368 -69
- package/src/prototype/utility.js +0 -227
- package/src/vars.js +10 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**FrostDateTime** is a free, open-source immutable date manipulation library for *JavaScript*.
|
|
4
4
|
|
|
5
|
-
It is a lightweight (~
|
|
5
|
+
It is a lightweight (~7kb gzipped) and modern library, and features support for ICU formats, time zones and locales.
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
## Table Of Contents
|
|
@@ -15,6 +15,8 @@ It is a lightweight (~6kb gzipped) and modern library, and features support for
|
|
|
15
15
|
- [Timestamps](#timestamps)
|
|
16
16
|
- [Time Zones](#time-zones)
|
|
17
17
|
- [Locales](#locales)
|
|
18
|
+
- [Manipulation](#manipulation)
|
|
19
|
+
- [Comparisons](#comparisons)
|
|
18
20
|
- [Utility Methods](#utility-methods)
|
|
19
21
|
- [Static Methods](#static-methods)
|
|
20
22
|
|
|
@@ -610,244 +612,1140 @@ const newDateTime = dateTime.setLocale(locale);
|
|
|
610
612
|
|
|
611
613
|
## Manipulation
|
|
612
614
|
|
|
613
|
-
**Add**
|
|
615
|
+
**Add Day**
|
|
614
616
|
|
|
615
|
-
Add a
|
|
617
|
+
Add a day to the current date.
|
|
616
618
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
+
```javascript
|
|
620
|
+
const newDateTime = dateTime.addDay();
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
**Add Days**
|
|
624
|
+
|
|
625
|
+
Add days to the current date.
|
|
626
|
+
|
|
627
|
+
- `amount` is a number representing the amount of days to add.
|
|
628
|
+
|
|
629
|
+
```javascript
|
|
630
|
+
const newDateTime = dateTime.addDay(amount);
|
|
631
|
+
```
|
|
632
|
+
|
|
633
|
+
**Add Hour**
|
|
634
|
+
|
|
635
|
+
Add a hour to the current date.
|
|
619
636
|
|
|
620
637
|
```javascript
|
|
621
|
-
const newDateTime = dateTime.
|
|
638
|
+
const newDateTime = dateTime.addHour();
|
|
622
639
|
```
|
|
623
640
|
|
|
624
|
-
**
|
|
641
|
+
**Add Hours**
|
|
642
|
+
|
|
643
|
+
Add hours to the current date.
|
|
644
|
+
|
|
645
|
+
- `amount` is a number representing the amount of hours to add.
|
|
625
646
|
|
|
626
|
-
|
|
647
|
+
```javascript
|
|
648
|
+
const newDateTime = dateTime.addHours(amount);
|
|
649
|
+
```
|
|
627
650
|
|
|
628
|
-
|
|
651
|
+
**Add Minute**
|
|
652
|
+
|
|
653
|
+
Add a minute to the current date.
|
|
629
654
|
|
|
630
655
|
```javascript
|
|
631
|
-
const newDateTime = dateTime.
|
|
656
|
+
const newDateTime = dateTime.addMinute();
|
|
632
657
|
```
|
|
633
658
|
|
|
634
|
-
**
|
|
659
|
+
**Add Minutes**
|
|
635
660
|
|
|
636
|
-
|
|
661
|
+
Add minutes to the current date.
|
|
637
662
|
|
|
638
|
-
- `
|
|
663
|
+
- `amount` is a number representing the amount of minutes to add.
|
|
639
664
|
|
|
640
665
|
```javascript
|
|
641
|
-
const newDateTime = dateTime.
|
|
666
|
+
const newDateTime = dateTime.addMinutes(amount);
|
|
642
667
|
```
|
|
643
668
|
|
|
644
|
-
**
|
|
669
|
+
**Add Month**
|
|
645
670
|
|
|
646
|
-
|
|
647
|
-
- `timeUnit` is a string representing the unit of time to subtract, and can be one of either "*year*", "*month*", "*week*", "*day*", "*hour*", "*minute*" or "*second*", or their pluralized versions.
|
|
671
|
+
Add a month to the current date.
|
|
648
672
|
|
|
649
673
|
```javascript
|
|
650
|
-
const newDateTime = dateTime.
|
|
674
|
+
const newDateTime = dateTime.addMonth();
|
|
651
675
|
```
|
|
652
676
|
|
|
677
|
+
**Add Months**
|
|
653
678
|
|
|
654
|
-
|
|
679
|
+
Add months to the current date.
|
|
655
680
|
|
|
656
|
-
|
|
681
|
+
- `amount` is a number representing the amount of months to add.
|
|
657
682
|
|
|
658
|
-
|
|
683
|
+
```javascript
|
|
684
|
+
const newDateTime = dateTime.addMonths(amount);
|
|
685
|
+
```
|
|
659
686
|
|
|
660
|
-
|
|
687
|
+
**Add Second**
|
|
688
|
+
|
|
689
|
+
Add a second to the current date.
|
|
661
690
|
|
|
662
691
|
```javascript
|
|
663
|
-
const
|
|
692
|
+
const newDateTime = dateTime.addSecond();
|
|
664
693
|
```
|
|
665
694
|
|
|
666
|
-
**
|
|
695
|
+
**Add Seconds**
|
|
667
696
|
|
|
668
|
-
|
|
697
|
+
Add seconds to the current date.
|
|
669
698
|
|
|
670
|
-
- `
|
|
699
|
+
- `amount` is a number representing the amount of seconds to add.
|
|
671
700
|
|
|
672
701
|
```javascript
|
|
673
|
-
const
|
|
702
|
+
const newDateTime = dateTime.addSeconds(amount);
|
|
674
703
|
```
|
|
675
704
|
|
|
676
|
-
**
|
|
705
|
+
**Add Week**
|
|
677
706
|
|
|
678
|
-
|
|
707
|
+
Add a week to the current date.
|
|
679
708
|
|
|
680
709
|
```javascript
|
|
681
|
-
const
|
|
710
|
+
const newDateTime = dateTime.addWeek();
|
|
682
711
|
```
|
|
683
712
|
|
|
684
|
-
**
|
|
713
|
+
**Add Weeks**
|
|
685
714
|
|
|
686
|
-
|
|
715
|
+
Add weeks to the current date.
|
|
716
|
+
|
|
717
|
+
- `amount` is a number representing the amount of weeks to add.
|
|
687
718
|
|
|
688
719
|
```javascript
|
|
689
|
-
const
|
|
720
|
+
const newDateTime = dateTime.addWeeks(amount);
|
|
690
721
|
```
|
|
691
722
|
|
|
692
|
-
**
|
|
723
|
+
**Add Year**
|
|
693
724
|
|
|
694
|
-
|
|
725
|
+
Add a year to the current date.
|
|
695
726
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
727
|
+
```javascript
|
|
728
|
+
const newDateTime = dateTime.addYear();
|
|
729
|
+
```
|
|
700
730
|
|
|
701
|
-
|
|
731
|
+
**Add Years**
|
|
732
|
+
|
|
733
|
+
Add years to the current date.
|
|
734
|
+
|
|
735
|
+
- `amount` is a number representing the amount of years to add.
|
|
702
736
|
|
|
703
737
|
```javascript
|
|
704
|
-
const
|
|
738
|
+
const newDateTime = dateTime.addYears(amount);
|
|
705
739
|
```
|
|
706
740
|
|
|
707
|
-
|
|
741
|
+
**End Of Day**
|
|
742
|
+
|
|
743
|
+
Set the date to the end of the day in current time zone.
|
|
708
744
|
|
|
709
745
|
```javascript
|
|
710
|
-
|
|
711
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').diff(DateTime.fromFormat('yyyy-MM-dd', '2018-12-31'), { timeUnit: 'years', relative: false }); // 0
|
|
712
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').diff(DateTime.fromFormat('yyyy-MM-dd', '2017-12-31'), { timeUnit: 'years', relative: true }); // 2
|
|
713
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').diff(DateTime.fromFormat('yyyy-MM-dd', '2017-12-31'), { timeUnit: 'years', relative: false }); // 1
|
|
746
|
+
const newDateTime = dateTime.endOfDay();
|
|
714
747
|
```
|
|
715
748
|
|
|
716
|
-
**
|
|
749
|
+
**End Of Hour**
|
|
717
750
|
|
|
718
|
-
|
|
751
|
+
Set the date to the end of the hour in current time zone.
|
|
719
752
|
|
|
720
|
-
|
|
753
|
+
```javascript
|
|
754
|
+
const newDateTime = dateTime.endOfHour();
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
**End Of Minute**
|
|
758
|
+
|
|
759
|
+
Set the date to the end of the minute in current time zone.
|
|
721
760
|
|
|
722
761
|
```javascript
|
|
723
|
-
const
|
|
762
|
+
const newDateTime = dateTime.endOfMinute();
|
|
724
763
|
```
|
|
725
764
|
|
|
726
|
-
**
|
|
765
|
+
**End Of Month**
|
|
727
766
|
|
|
728
|
-
|
|
767
|
+
Set the date to the end of the month in current time zone.
|
|
729
768
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
769
|
+
```javascript
|
|
770
|
+
const newDateTime = dateTime.endOfMonth();
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
**End Of Quarter**
|
|
733
774
|
|
|
734
|
-
|
|
775
|
+
Set the date to the end of the quarter in current time zone.
|
|
735
776
|
|
|
736
777
|
```javascript
|
|
737
|
-
const
|
|
778
|
+
const newDateTime = dateTime.endOfQuarter();
|
|
738
779
|
```
|
|
739
780
|
|
|
740
|
-
|
|
781
|
+
**End Of Second**
|
|
782
|
+
|
|
783
|
+
Set the date to the end of the second in current time zone.
|
|
741
784
|
|
|
742
785
|
```javascript
|
|
743
|
-
|
|
744
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-02-27').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2019-01-31')); // "in 27 days"
|
|
745
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-02-28').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2019-01-31')); // "next month"
|
|
746
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2018-06-01')); // "in 6 months"
|
|
747
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2018-01-31')); // "next year"
|
|
748
|
-
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2017-12-31')); // "in 2 years"
|
|
786
|
+
const newDateTime = dateTime.endOfSecond();
|
|
749
787
|
```
|
|
750
788
|
|
|
751
|
-
**
|
|
789
|
+
**End Of Week**
|
|
752
790
|
|
|
753
|
-
|
|
791
|
+
Set the date to the end of the week in current time zone.
|
|
792
|
+
|
|
793
|
+
```javascript
|
|
794
|
+
const newDateTime = dateTime.endOfWeek();
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
**End Of Year**
|
|
798
|
+
|
|
799
|
+
Set the date to the end of the year in current time zone.
|
|
800
|
+
|
|
801
|
+
```javascript
|
|
802
|
+
const newDateTime = dateTime.endOfYear();
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
**Start Of Day**
|
|
806
|
+
|
|
807
|
+
Set the date to the start of the day in current time zone.
|
|
808
|
+
|
|
809
|
+
```javascript
|
|
810
|
+
const newDateTime = dateTime.startOfDay();
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
**Start Of Hour**
|
|
814
|
+
|
|
815
|
+
Set the date to the start of the hour in current time zone.
|
|
816
|
+
|
|
817
|
+
```javascript
|
|
818
|
+
const newDateTime = dateTime.startOfHour();
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
**Start Of Minute**
|
|
822
|
+
|
|
823
|
+
Set the date to the start of the minute in current time zone.
|
|
824
|
+
|
|
825
|
+
```javascript
|
|
826
|
+
const newDateTime = dateTime.startOfMinute();
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
**Start Of Month**
|
|
830
|
+
|
|
831
|
+
Set the date to the start of the month in current time zone.
|
|
832
|
+
|
|
833
|
+
```javascript
|
|
834
|
+
const newDateTime = dateTime.startOfMonth();
|
|
835
|
+
```
|
|
836
|
+
|
|
837
|
+
**Start Of Quarter**
|
|
838
|
+
|
|
839
|
+
Set the date to the start of the quarter in current time zone.
|
|
840
|
+
|
|
841
|
+
```javascript
|
|
842
|
+
const newDateTime = dateTime.startOfQuarter();
|
|
843
|
+
```
|
|
844
|
+
|
|
845
|
+
**Start Of Second**
|
|
846
|
+
|
|
847
|
+
Set the date to the start of the second in current time zone.
|
|
848
|
+
|
|
849
|
+
```javascript
|
|
850
|
+
const newDateTime = dateTime.startOfSecond();
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
**Start Of Week**
|
|
854
|
+
|
|
855
|
+
Set the date to the start of the week in current time zone.
|
|
856
|
+
|
|
857
|
+
```javascript
|
|
858
|
+
const newDateTime = dateTime.startOfWeek();
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
**Start Of Year**
|
|
862
|
+
|
|
863
|
+
Set the date to the start of the year in current time zone.
|
|
864
|
+
|
|
865
|
+
```javascript
|
|
866
|
+
const newDateTime = dateTime.startOfYear();
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
**Subtract Day**
|
|
870
|
+
|
|
871
|
+
Subtract a day to the current date.
|
|
872
|
+
|
|
873
|
+
```javascript
|
|
874
|
+
const newDateTime = dateTime.subtractDay();
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
**Subtract Days**
|
|
878
|
+
|
|
879
|
+
Subtract days to the current date.
|
|
880
|
+
|
|
881
|
+
- `amount` is a number representing the amount of days to subtract.
|
|
882
|
+
|
|
883
|
+
```javascript
|
|
884
|
+
const newDateTime = dateTime.subtractDay(amount);
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
**Subtract Hour**
|
|
888
|
+
|
|
889
|
+
Subtract a hour to the current date.
|
|
890
|
+
|
|
891
|
+
```javascript
|
|
892
|
+
const newDateTime = dateTime.subtractHour();
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
**Subtract Hours**
|
|
896
|
+
|
|
897
|
+
Subtract hours to the current date.
|
|
898
|
+
|
|
899
|
+
- `amount` is a number representing the amount of hours to subtract.
|
|
900
|
+
|
|
901
|
+
```javascript
|
|
902
|
+
const newDateTime = dateTime.subtractHours(amount);
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
**Subtract Minute**
|
|
906
|
+
|
|
907
|
+
Subtract a minute to the current date.
|
|
908
|
+
|
|
909
|
+
```javascript
|
|
910
|
+
const newDateTime = dateTime.subtractMinute();
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
**Subtract Minutes**
|
|
914
|
+
|
|
915
|
+
Subtract minutes to the current date.
|
|
916
|
+
|
|
917
|
+
- `amount` is a number representing the amount of minutes to subtract.
|
|
918
|
+
|
|
919
|
+
```javascript
|
|
920
|
+
const newDateTime = dateTime.subtractMinutes(amount);
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
**Subtract Month**
|
|
924
|
+
|
|
925
|
+
Subtract a month to the current date.
|
|
926
|
+
|
|
927
|
+
```javascript
|
|
928
|
+
const newDateTime = dateTime.subtractMonth();
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
**Subtract Months**
|
|
932
|
+
|
|
933
|
+
Subtract months to the current date.
|
|
934
|
+
|
|
935
|
+
- `amount` is a number representing the amount of months to subtract.
|
|
936
|
+
|
|
937
|
+
```javascript
|
|
938
|
+
const newDateTime = dateTime.subtractMonths(amount);
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
**Subtract Second**
|
|
942
|
+
|
|
943
|
+
Subtract a second to the current date.
|
|
944
|
+
|
|
945
|
+
```javascript
|
|
946
|
+
const newDateTime = dateTime.subtractSecond();
|
|
947
|
+
```
|
|
948
|
+
|
|
949
|
+
**Subtract Seconds**
|
|
950
|
+
|
|
951
|
+
Subtract seconds to the current date.
|
|
952
|
+
|
|
953
|
+
- `amount` is a number representing the amount of seconds to subtract.
|
|
954
|
+
|
|
955
|
+
```javascript
|
|
956
|
+
const newDateTime = dateTime.subtractSeconds(amount);
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
**Subtract Week**
|
|
960
|
+
|
|
961
|
+
Subtract a week to the current date.
|
|
962
|
+
|
|
963
|
+
```javascript
|
|
964
|
+
const newDateTime = dateTime.subtractWeek();
|
|
965
|
+
```
|
|
966
|
+
|
|
967
|
+
**Subtract Weeks**
|
|
968
|
+
|
|
969
|
+
Subtract weeks to the current date.
|
|
970
|
+
|
|
971
|
+
- `amount` is a number representing the amount of weeks to subtract.
|
|
972
|
+
|
|
973
|
+
```javascript
|
|
974
|
+
const newDateTime = dateTime.subtractWeeks(amount);
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
**Subtract Year**
|
|
978
|
+
|
|
979
|
+
Subtract a year to the current date.
|
|
980
|
+
|
|
981
|
+
```javascript
|
|
982
|
+
const newDateTime = dateTime.subtractYear();
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
**Subtract Years**
|
|
986
|
+
|
|
987
|
+
Subtract years to the current date.
|
|
988
|
+
|
|
989
|
+
- `amount` is a number representing the amount of years to subtract.
|
|
990
|
+
|
|
991
|
+
```javascript
|
|
992
|
+
const newDateTime = dateTime.subtractYears(amount);
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
## Comparisons
|
|
997
|
+
|
|
998
|
+
**Difference**
|
|
999
|
+
|
|
1000
|
+
Get the difference between two dates in milliseconds.
|
|
1001
|
+
|
|
1002
|
+
- `other` is the *DateTime* object to compare to.
|
|
1003
|
+
|
|
1004
|
+
```javascript
|
|
1005
|
+
const diff = dateTime.diff(other);
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
**Difference In Days**
|
|
1009
|
+
|
|
1010
|
+
Get the difference between two dates in days.
|
|
754
1011
|
|
|
755
1012
|
- `other` is the *DateTime* object to compare to.
|
|
756
1013
|
- `options` is an object containing options for how to compare the dates.
|
|
757
|
-
- `
|
|
1014
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
758
1015
|
|
|
759
1016
|
```javascript
|
|
760
|
-
const
|
|
1017
|
+
const diff = dateTime.diffInDays(other, options);
|
|
761
1018
|
```
|
|
762
1019
|
|
|
763
|
-
If
|
|
1020
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
764
1021
|
|
|
765
|
-
**
|
|
1022
|
+
**Difference In Hours**
|
|
766
1023
|
|
|
767
|
-
|
|
1024
|
+
Get the difference between two dates in hours.
|
|
768
1025
|
|
|
769
1026
|
- `other` is the *DateTime* object to compare to.
|
|
770
1027
|
- `options` is an object containing options for how to compare the dates.
|
|
771
|
-
- `
|
|
1028
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
772
1029
|
|
|
773
1030
|
```javascript
|
|
774
|
-
const
|
|
1031
|
+
const diff = dateTime.diffInHours(other, options);
|
|
775
1032
|
```
|
|
776
1033
|
|
|
777
|
-
If
|
|
1034
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
778
1035
|
|
|
779
|
-
**
|
|
1036
|
+
**Difference In Minutes**
|
|
780
1037
|
|
|
781
|
-
|
|
1038
|
+
Get the difference between two dates in minutes.
|
|
782
1039
|
|
|
783
|
-
- `
|
|
784
|
-
- `end` is the ending *DateTime* object to compare to.
|
|
1040
|
+
- `other` is the *DateTime* object to compare to.
|
|
785
1041
|
- `options` is an object containing options for how to compare the dates.
|
|
786
|
-
- `
|
|
1042
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
787
1043
|
|
|
788
1044
|
```javascript
|
|
789
|
-
const
|
|
1045
|
+
const diff = dateTime.diffInMinutes(other, options);
|
|
790
1046
|
```
|
|
791
1047
|
|
|
792
|
-
If
|
|
1048
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
793
1049
|
|
|
794
|
-
**
|
|
1050
|
+
**Difference In Months**
|
|
795
1051
|
|
|
796
|
-
|
|
1052
|
+
Get the difference between two dates in months.
|
|
1053
|
+
|
|
1054
|
+
- `other` is the *DateTime* object to compare to.
|
|
1055
|
+
- `options` is an object containing options for how to compare the dates.
|
|
1056
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
797
1057
|
|
|
798
1058
|
```javascript
|
|
799
|
-
const
|
|
1059
|
+
const diff = dateTime.diffInMonths(other, options);
|
|
800
1060
|
```
|
|
801
1061
|
|
|
802
|
-
|
|
1062
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
803
1063
|
|
|
804
|
-
|
|
1064
|
+
**Difference In Seconds**
|
|
1065
|
+
|
|
1066
|
+
Get the difference between two dates in seconds.
|
|
1067
|
+
|
|
1068
|
+
- `other` is the *DateTime* object to compare to.
|
|
1069
|
+
- `options` is an object containing options for how to compare the dates.
|
|
1070
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
805
1071
|
|
|
806
1072
|
```javascript
|
|
807
|
-
const
|
|
1073
|
+
const diff = dateTime.diffInSeconds(other, options);
|
|
808
1074
|
```
|
|
809
1075
|
|
|
810
|
-
|
|
1076
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
811
1077
|
|
|
812
|
-
|
|
1078
|
+
**Difference In Weeks**
|
|
1079
|
+
|
|
1080
|
+
Get the difference between two dates in weeks.
|
|
813
1081
|
|
|
814
1082
|
- `other` is the *DateTime* object to compare to.
|
|
815
1083
|
- `options` is an object containing options for how to compare the dates.
|
|
816
|
-
- `
|
|
1084
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
817
1085
|
|
|
818
1086
|
```javascript
|
|
819
|
-
const
|
|
1087
|
+
const diff = dateTime.diffInWeeks(other, options);
|
|
820
1088
|
```
|
|
821
1089
|
|
|
822
|
-
If
|
|
1090
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
823
1091
|
|
|
824
|
-
**
|
|
1092
|
+
**Difference In Years**
|
|
825
1093
|
|
|
826
|
-
|
|
1094
|
+
Get the difference between two dates in years.
|
|
827
1095
|
|
|
828
1096
|
- `other` is the *DateTime* object to compare to.
|
|
829
1097
|
- `options` is an object containing options for how to compare the dates.
|
|
830
|
-
- `
|
|
1098
|
+
- `relative` is a boolean indicating whether to return the relative difference, and will default to *true*.
|
|
831
1099
|
|
|
832
1100
|
```javascript
|
|
833
|
-
const
|
|
1101
|
+
const diff = dateTime.diffInYears(other, options);
|
|
834
1102
|
```
|
|
835
1103
|
|
|
836
|
-
If
|
|
1104
|
+
If `relative` is *true* (default) the value returned will be the relative difference, ignoring higher precision properties.
|
|
837
1105
|
|
|
838
|
-
**
|
|
1106
|
+
**Human Difference**
|
|
839
1107
|
|
|
840
|
-
|
|
1108
|
+
Get the relative difference between two Dates in a human readable format using the current locale.
|
|
841
1109
|
|
|
842
1110
|
- `other` is the *DateTime* object to compare to.
|
|
843
|
-
- `options` is an object containing options for how to compare the dates.
|
|
844
|
-
- `granularity` is a string specifying the level of granularity to use when comparing the dates, and can be one of either "*year*", "*month*", "*day*", "*hour*", "*minute*" or "*second*".
|
|
845
1111
|
|
|
846
1112
|
```javascript
|
|
847
|
-
const
|
|
1113
|
+
const humanDiff = dateTime.humanDiff(other);
|
|
848
1114
|
```
|
|
849
1115
|
|
|
850
|
-
|
|
1116
|
+
The most significant non-zero value is determined where the unit of time has a non-relative difference, or the next relative difference value is greater than or equal to the unit of time.
|
|
1117
|
+
|
|
1118
|
+
```javascript
|
|
1119
|
+
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2018-12-31')); // "tomorrow"
|
|
1120
|
+
DateTime.fromFormat('yyyy-MM-dd', '2019-02-27').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2019-01-31')); // "in 27 days"
|
|
1121
|
+
DateTime.fromFormat('yyyy-MM-dd', '2019-02-28').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2019-01-31')); // "next month"
|
|
1122
|
+
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2018-06-01')); // "in 6 months"
|
|
1123
|
+
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2018-01-31')); // "next year"
|
|
1124
|
+
DateTime.fromFormat('yyyy-MM-dd', '2019-01-01').humanDiff(DateTime.fromFormat('yyyy-MM-dd', '2017-12-31')); // "in 2 years"
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
**Human Difference In Days**
|
|
1128
|
+
|
|
1129
|
+
Get the relative difference between two Dates in days in a human readable format using the current locale.
|
|
1130
|
+
|
|
1131
|
+
- `other` is the *DateTime* object to compare to.
|
|
1132
|
+
|
|
1133
|
+
```javascript
|
|
1134
|
+
const humanDiff = dateTime.humanDiffInDays(other);
|
|
1135
|
+
```
|
|
1136
|
+
|
|
1137
|
+
**Human Difference In Hours**
|
|
1138
|
+
|
|
1139
|
+
Get the relative difference between two Dates in hours in a human readable format using the current locale.
|
|
1140
|
+
|
|
1141
|
+
- `other` is the *DateTime* object to compare to.
|
|
1142
|
+
|
|
1143
|
+
```javascript
|
|
1144
|
+
const humanDiff = dateTime.humanDiffInHours(other);
|
|
1145
|
+
```
|
|
1146
|
+
|
|
1147
|
+
**Human Difference In Minutes**
|
|
1148
|
+
|
|
1149
|
+
Get the relative difference between two Dates in minutes in a human readable format using the current locale.
|
|
1150
|
+
|
|
1151
|
+
- `other` is the *DateTime* object to compare to.
|
|
1152
|
+
|
|
1153
|
+
```javascript
|
|
1154
|
+
const humanDiff = dateTime.humanDiffInMinutes(other);
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
**Human Difference In Months**
|
|
1158
|
+
|
|
1159
|
+
Get the relative difference between two Dates in months in a human readable format using the current locale.
|
|
1160
|
+
|
|
1161
|
+
- `other` is the *DateTime* object to compare to.
|
|
1162
|
+
|
|
1163
|
+
```javascript
|
|
1164
|
+
const humanDiff = dateTime.humanDiffInMonths(other);
|
|
1165
|
+
```
|
|
1166
|
+
|
|
1167
|
+
**Human Difference In Seconds**
|
|
1168
|
+
|
|
1169
|
+
Get the relative difference between two Dates in seconds in a human readable format using the current locale.
|
|
1170
|
+
|
|
1171
|
+
- `other` is the *DateTime* object to compare to.
|
|
1172
|
+
|
|
1173
|
+
```javascript
|
|
1174
|
+
const humanDiff = dateTime.humanDiffInSeconds(other);
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
**Human Difference In Weeks**
|
|
1178
|
+
|
|
1179
|
+
Get the relative difference between two Dates in weeks in a human readable format using the current locale.
|
|
1180
|
+
|
|
1181
|
+
- `other` is the *DateTime* object to compare to.
|
|
1182
|
+
|
|
1183
|
+
```javascript
|
|
1184
|
+
const humanDiff = dateTime.humanDiffInWeeks(other);
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
**Human Difference In Years**
|
|
1188
|
+
|
|
1189
|
+
Get the relative difference between two Dates in years in a human readable format using the current locale.
|
|
1190
|
+
|
|
1191
|
+
- `other` is the *DateTime* object to compare to.
|
|
1192
|
+
|
|
1193
|
+
```javascript
|
|
1194
|
+
const humanDiff = dateTime.humanDiffInYears(other);
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1197
|
+
**Is After?**
|
|
1198
|
+
|
|
1199
|
+
Return *true* if the *DateTime* is after another date.
|
|
1200
|
+
|
|
1201
|
+
- `other` is the *DateTime* object to compare to.
|
|
1202
|
+
|
|
1203
|
+
```javascript
|
|
1204
|
+
const isAfter = dateTime.isAfter(other);
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
**Is After Day?**
|
|
1208
|
+
|
|
1209
|
+
Return *true* if the *DateTime* is after another date (comparing by day).
|
|
1210
|
+
|
|
1211
|
+
- `other` is the *DateTime* object to compare to.
|
|
1212
|
+
|
|
1213
|
+
```javascript
|
|
1214
|
+
const isAfter = dateTime.isAfterDay(other);
|
|
1215
|
+
```
|
|
1216
|
+
|
|
1217
|
+
**Is After Hour?**
|
|
1218
|
+
|
|
1219
|
+
Return *true* if the *DateTime* is after another date (comparing by hour).
|
|
1220
|
+
|
|
1221
|
+
- `other` is the *DateTime* object to compare to.
|
|
1222
|
+
|
|
1223
|
+
```javascript
|
|
1224
|
+
const isAfter = dateTime.isAfterHour(other);
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
**Is After Minute?**
|
|
1228
|
+
|
|
1229
|
+
Return *true* if the *DateTime* is after another date (comparing by minute).
|
|
1230
|
+
|
|
1231
|
+
- `other` is the *DateTime* object to compare to.
|
|
1232
|
+
|
|
1233
|
+
```javascript
|
|
1234
|
+
const isAfter = dateTime.isAfterMinute(other);
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
**Is After Month?**
|
|
1238
|
+
|
|
1239
|
+
Return *true* if the *DateTime* is after another date (comparing by month).
|
|
1240
|
+
|
|
1241
|
+
- `other` is the *DateTime* object to compare to.
|
|
1242
|
+
|
|
1243
|
+
```javascript
|
|
1244
|
+
const isAfter = dateTime.isAfterMonth(other);
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
**Is After Second?**
|
|
1248
|
+
|
|
1249
|
+
Return *true* if the *DateTime* is after another date (comparing by second).
|
|
1250
|
+
|
|
1251
|
+
- `other` is the *DateTime* object to compare to.
|
|
1252
|
+
|
|
1253
|
+
```javascript
|
|
1254
|
+
const isAfter = dateTime.isAfterSecond(other);
|
|
1255
|
+
```
|
|
1256
|
+
|
|
1257
|
+
**Is After Week?**
|
|
1258
|
+
|
|
1259
|
+
Return *true* if the *DateTime* is after another date (comparing by week).
|
|
1260
|
+
|
|
1261
|
+
- `other` is the *DateTime* object to compare to.
|
|
1262
|
+
|
|
1263
|
+
```javascript
|
|
1264
|
+
const isAfter = dateTime.isAfterWeek(other);
|
|
1265
|
+
```
|
|
1266
|
+
|
|
1267
|
+
**Is After Year?**
|
|
1268
|
+
|
|
1269
|
+
Return *true* if the *DateTime* is after another date (comparing by year).
|
|
1270
|
+
|
|
1271
|
+
- `other` is the *DateTime* object to compare to.
|
|
1272
|
+
|
|
1273
|
+
```javascript
|
|
1274
|
+
const isAfter = dateTime.isAfterYear(other);
|
|
1275
|
+
```
|
|
1276
|
+
|
|
1277
|
+
**Is Before?**
|
|
1278
|
+
|
|
1279
|
+
Return *true* if the *DateTime* is before another date.
|
|
1280
|
+
|
|
1281
|
+
- `other` is the *DateTime* object to compare to.
|
|
1282
|
+
|
|
1283
|
+
```javascript
|
|
1284
|
+
const isBefore = dateTime.isBefore(other);
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
**Is Before Day?**
|
|
1288
|
+
|
|
1289
|
+
Return *true* if the *DateTime* is before another date (comparing by day).
|
|
1290
|
+
|
|
1291
|
+
- `other` is the *DateTime* object to compare to.
|
|
1292
|
+
|
|
1293
|
+
```javascript
|
|
1294
|
+
const isBefore = dateTime.isBeforeDay(other);
|
|
1295
|
+
```
|
|
1296
|
+
|
|
1297
|
+
**Is Before Hour?**
|
|
1298
|
+
|
|
1299
|
+
Return *true* if the *DateTime* is before another date (comparing by hour).
|
|
1300
|
+
|
|
1301
|
+
- `other` is the *DateTime* object to compare to.
|
|
1302
|
+
|
|
1303
|
+
```javascript
|
|
1304
|
+
const isBefore = dateTime.isBeforeHour(other);
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
**Is Before Minute?**
|
|
1308
|
+
|
|
1309
|
+
Return *true* if the *DateTime* is before another date (comparing by minute).
|
|
1310
|
+
|
|
1311
|
+
- `other` is the *DateTime* object to compare to.
|
|
1312
|
+
|
|
1313
|
+
```javascript
|
|
1314
|
+
const isBefore = dateTime.isBeforeMinute(other);
|
|
1315
|
+
```
|
|
1316
|
+
|
|
1317
|
+
**Is Before Month?**
|
|
1318
|
+
|
|
1319
|
+
Return *true* if the *DateTime* is before another date (comparing by month).
|
|
1320
|
+
|
|
1321
|
+
- `other` is the *DateTime* object to compare to.
|
|
1322
|
+
|
|
1323
|
+
```javascript
|
|
1324
|
+
const isBefore = dateTime.isBeforeMonth(other);
|
|
1325
|
+
```
|
|
1326
|
+
|
|
1327
|
+
**Is Before Second?**
|
|
1328
|
+
|
|
1329
|
+
Return *true* if the *DateTime* is before another date (comparing by second).
|
|
1330
|
+
|
|
1331
|
+
- `other` is the *DateTime* object to compare to.
|
|
1332
|
+
|
|
1333
|
+
```javascript
|
|
1334
|
+
const isBefore = dateTime.isBeforeSecond(other);
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
**Is Before Week?**
|
|
1338
|
+
|
|
1339
|
+
Return *true* if the *DateTime* is before another date (comparing by week).
|
|
1340
|
+
|
|
1341
|
+
- `other` is the *DateTime* object to compare to.
|
|
1342
|
+
|
|
1343
|
+
```javascript
|
|
1344
|
+
const isBefore = dateTime.isBeforeWeek(other);
|
|
1345
|
+
```
|
|
1346
|
+
|
|
1347
|
+
**Is Before Year?**
|
|
1348
|
+
|
|
1349
|
+
Return *true* if the *DateTime* is before another date (comparing by year).
|
|
1350
|
+
|
|
1351
|
+
- `other` is the *DateTime* object to compare to.
|
|
1352
|
+
|
|
1353
|
+
```javascript
|
|
1354
|
+
const isBefore = dateTime.isBeforeYear(other);
|
|
1355
|
+
```
|
|
1356
|
+
|
|
1357
|
+
**Is Between?**
|
|
1358
|
+
|
|
1359
|
+
Return *true* if the *DateTime* is between two other dates.
|
|
1360
|
+
|
|
1361
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1362
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1363
|
+
|
|
1364
|
+
```javascript
|
|
1365
|
+
const isBetween = dateTime.isBetween(start, end);
|
|
1366
|
+
```
|
|
1367
|
+
|
|
1368
|
+
**Is Between Day?**
|
|
1369
|
+
|
|
1370
|
+
Return *true* if the *DateTime* is between two other dates (comparing by day).
|
|
1371
|
+
|
|
1372
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1373
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1374
|
+
|
|
1375
|
+
```javascript
|
|
1376
|
+
const isBetween = dateTime.isBetweenDay(start, end);
|
|
1377
|
+
```
|
|
1378
|
+
|
|
1379
|
+
**Is Between Hour?**
|
|
1380
|
+
|
|
1381
|
+
Return *true* if the *DateTime* is between two other dates (comparing by hour).
|
|
1382
|
+
|
|
1383
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1384
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1385
|
+
|
|
1386
|
+
```javascript
|
|
1387
|
+
const isBetween = dateTime.isBetweenHour(start, end);
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
**Is Between Minute?**
|
|
1391
|
+
|
|
1392
|
+
Return *true* if the *DateTime* is between two other dates (comparing by minute).
|
|
1393
|
+
|
|
1394
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1395
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1396
|
+
|
|
1397
|
+
```javascript
|
|
1398
|
+
const isBetween = dateTime.isBetweenMinute(start, end);
|
|
1399
|
+
```
|
|
1400
|
+
|
|
1401
|
+
**Is Between Month?**
|
|
1402
|
+
|
|
1403
|
+
Return *true* if the *DateTime* is between two other dates (comparing by month).
|
|
1404
|
+
|
|
1405
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1406
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1407
|
+
|
|
1408
|
+
```javascript
|
|
1409
|
+
const isBetween = dateTime.isBetweenMonth(start, end);
|
|
1410
|
+
```
|
|
1411
|
+
|
|
1412
|
+
**Is Between Second?**
|
|
1413
|
+
|
|
1414
|
+
Return *true* if the *DateTime* is between two other dates (comparing by second).
|
|
1415
|
+
|
|
1416
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1417
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1418
|
+
|
|
1419
|
+
```javascript
|
|
1420
|
+
const isBetween = dateTime.isBetweenSecond(start, end);
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
**Is Between Week?**
|
|
1424
|
+
|
|
1425
|
+
Return *true* if the *DateTime* is between two other dates (comparing by week).
|
|
1426
|
+
|
|
1427
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1428
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1429
|
+
|
|
1430
|
+
```javascript
|
|
1431
|
+
const isBetween = dateTime.isBetweenWeek(start, end);
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
**Is Between Year?**
|
|
1435
|
+
|
|
1436
|
+
Return *true* if the *DateTime* is between two other dates (comparing by year).
|
|
1437
|
+
|
|
1438
|
+
- `start` is the starting *DateTime* object to compare to.
|
|
1439
|
+
- `end` is the ending *DateTime* object to compare to.
|
|
1440
|
+
|
|
1441
|
+
```javascript
|
|
1442
|
+
const isBetween = dateTime.isBetweenYear(start, end);
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
**Is Same?**
|
|
1446
|
+
|
|
1447
|
+
Return *true* if the *DateTime* is the same as another date.
|
|
1448
|
+
|
|
1449
|
+
- `other` is the *DateTime* object to compare to.
|
|
1450
|
+
|
|
1451
|
+
```javascript
|
|
1452
|
+
const isSame = dateTime.isSame(other);
|
|
1453
|
+
```
|
|
1454
|
+
|
|
1455
|
+
**Is Same Day?**
|
|
1456
|
+
|
|
1457
|
+
Return *true* if the *DateTime* is the same as another date (comparing by day).
|
|
1458
|
+
|
|
1459
|
+
- `other` is the *DateTime* object to compare to.
|
|
1460
|
+
|
|
1461
|
+
```javascript
|
|
1462
|
+
const isSame = dateTime.isSameDay(other);
|
|
1463
|
+
```
|
|
1464
|
+
|
|
1465
|
+
**Is Same Hour?**
|
|
1466
|
+
|
|
1467
|
+
Return *true* if the *DateTime* is the same as another date (comparing by hour).
|
|
1468
|
+
|
|
1469
|
+
- `other` is the *DateTime* object to compare to.
|
|
1470
|
+
|
|
1471
|
+
```javascript
|
|
1472
|
+
const isSame = dateTime.isSameHour(other);
|
|
1473
|
+
```
|
|
1474
|
+
|
|
1475
|
+
**Is Same Minute?**
|
|
1476
|
+
|
|
1477
|
+
Return *true* if the *DateTime* is the same as another date (comparing by minute).
|
|
1478
|
+
|
|
1479
|
+
- `other` is the *DateTime* object to compare to.
|
|
1480
|
+
|
|
1481
|
+
```javascript
|
|
1482
|
+
const isSame = dateTime.isSameMinute(other);
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
**Is Same Month?**
|
|
1486
|
+
|
|
1487
|
+
Return *true* if the *DateTime* is the same as another date (comparing by month).
|
|
1488
|
+
|
|
1489
|
+
- `other` is the *DateTime* object to compare to.
|
|
1490
|
+
|
|
1491
|
+
```javascript
|
|
1492
|
+
const isSame = dateTime.isSameMonth(other);
|
|
1493
|
+
```
|
|
1494
|
+
|
|
1495
|
+
**Is Same Second?**
|
|
1496
|
+
|
|
1497
|
+
Return *true* if the *DateTime* is the same as another date (comparing by second).
|
|
1498
|
+
|
|
1499
|
+
- `other` is the *DateTime* object to compare to.
|
|
1500
|
+
|
|
1501
|
+
```javascript
|
|
1502
|
+
const isSame = dateTime.isSameSecond(other);
|
|
1503
|
+
```
|
|
1504
|
+
|
|
1505
|
+
**Is Same Week?**
|
|
1506
|
+
|
|
1507
|
+
Return *true* if the *DateTime* is the same as another date (comparing by week).
|
|
1508
|
+
|
|
1509
|
+
- `other` is the *DateTime* object to compare to.
|
|
1510
|
+
|
|
1511
|
+
```javascript
|
|
1512
|
+
const isSame = dateTime.isSameWeek(other);
|
|
1513
|
+
```
|
|
1514
|
+
|
|
1515
|
+
**Is Same Year?**
|
|
1516
|
+
|
|
1517
|
+
Return *true* if the *DateTime* is the same as another date (comparing by year).
|
|
1518
|
+
|
|
1519
|
+
- `other` is the *DateTime* object to compare to.
|
|
1520
|
+
|
|
1521
|
+
```javascript
|
|
1522
|
+
const isSame = dateTime.isSameYear(other);
|
|
1523
|
+
```
|
|
1524
|
+
|
|
1525
|
+
**Is Same Or After?**
|
|
1526
|
+
|
|
1527
|
+
Return *true* if the *DateTime* is the same as or after another date.
|
|
1528
|
+
|
|
1529
|
+
- `other` is the *DateTime* object to compare to.
|
|
1530
|
+
|
|
1531
|
+
```javascript
|
|
1532
|
+
const isSameOrAfter = dateTime.isSameOrAfter(other);
|
|
1533
|
+
```
|
|
1534
|
+
|
|
1535
|
+
**Is Same Or After Day?**
|
|
1536
|
+
|
|
1537
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by day).
|
|
1538
|
+
|
|
1539
|
+
- `other` is the *DateTime* object to compare to.
|
|
1540
|
+
|
|
1541
|
+
```javascript
|
|
1542
|
+
const isSameOrAfter = dateTime.isSameOrAfterDay(other);
|
|
1543
|
+
```
|
|
1544
|
+
|
|
1545
|
+
**Is Same Or After Hour?**
|
|
1546
|
+
|
|
1547
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by hour).
|
|
1548
|
+
|
|
1549
|
+
- `other` is the *DateTime* object to compare to.
|
|
1550
|
+
|
|
1551
|
+
```javascript
|
|
1552
|
+
const isSameOrAfter = dateTime.isSameOrAfterHour(other);
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
**Is Same Or After Minute?**
|
|
1556
|
+
|
|
1557
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by minute).
|
|
1558
|
+
|
|
1559
|
+
- `other` is the *DateTime* object to compare to.
|
|
1560
|
+
|
|
1561
|
+
```javascript
|
|
1562
|
+
const isSameOrAfter = dateTime.isSameOrAfterMinute(other);
|
|
1563
|
+
```
|
|
1564
|
+
|
|
1565
|
+
**Is Same Or After Month?**
|
|
1566
|
+
|
|
1567
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by month).
|
|
1568
|
+
|
|
1569
|
+
- `other` is the *DateTime* object to compare to.
|
|
1570
|
+
|
|
1571
|
+
```javascript
|
|
1572
|
+
const isSameOrAfter = dateTime.isSameOrAfterMonth(other);
|
|
1573
|
+
```
|
|
1574
|
+
|
|
1575
|
+
**Is Same Or After Second?**
|
|
1576
|
+
|
|
1577
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by second).
|
|
1578
|
+
|
|
1579
|
+
- `other` is the *DateTime* object to compare to.
|
|
1580
|
+
|
|
1581
|
+
```javascript
|
|
1582
|
+
const isSameOrAfter = dateTime.isSameOrAfterSecond(other);
|
|
1583
|
+
```
|
|
1584
|
+
|
|
1585
|
+
**Is Same Or After Week?**
|
|
1586
|
+
|
|
1587
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by week).
|
|
1588
|
+
|
|
1589
|
+
- `other` is the *DateTime* object to compare to.
|
|
1590
|
+
|
|
1591
|
+
```javascript
|
|
1592
|
+
const isSameOrAfter = dateTime.isSameOrAfterWeek(other);
|
|
1593
|
+
```
|
|
1594
|
+
|
|
1595
|
+
**Is Same Or After Year?**
|
|
1596
|
+
|
|
1597
|
+
Return *true* if the *DateTime* is the same as or after another date (comparing by year).
|
|
1598
|
+
|
|
1599
|
+
- `other` is the *DateTime* object to compare to.
|
|
1600
|
+
|
|
1601
|
+
```javascript
|
|
1602
|
+
const isSameOrAfter = dateTime.isSameOrAfterYear(other);
|
|
1603
|
+
```
|
|
1604
|
+
|
|
1605
|
+
**Is Same Or Before?**
|
|
1606
|
+
|
|
1607
|
+
Return *true* if the *DateTime* is the same as or before another date.
|
|
1608
|
+
|
|
1609
|
+
- `other` is the *DateTime* object to compare to.
|
|
1610
|
+
|
|
1611
|
+
```javascript
|
|
1612
|
+
const isSameOrBefore = dateTime.isSameOrBefore(other);
|
|
1613
|
+
```
|
|
1614
|
+
|
|
1615
|
+
**Is Same Or Before Day?**
|
|
1616
|
+
|
|
1617
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by day).
|
|
1618
|
+
|
|
1619
|
+
- `other` is the *DateTime* object to compare to.
|
|
1620
|
+
|
|
1621
|
+
```javascript
|
|
1622
|
+
const isSameOrBefore = dateTime.isSameOrBeforeDay(other);
|
|
1623
|
+
```
|
|
1624
|
+
|
|
1625
|
+
**Is Same Or Before Hour?**
|
|
1626
|
+
|
|
1627
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by hour).
|
|
1628
|
+
|
|
1629
|
+
- `other` is the *DateTime* object to compare to.
|
|
1630
|
+
|
|
1631
|
+
```javascript
|
|
1632
|
+
const isSameOrBefore = dateTime.isSameOrBeforeHour(other);
|
|
1633
|
+
```
|
|
1634
|
+
|
|
1635
|
+
**Is Same Or Before Minute?**
|
|
1636
|
+
|
|
1637
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by minute).
|
|
1638
|
+
|
|
1639
|
+
- `other` is the *DateTime* object to compare to.
|
|
1640
|
+
|
|
1641
|
+
```javascript
|
|
1642
|
+
const isSameOrBefore = dateTime.isSameOrBeforeMinute(other);
|
|
1643
|
+
```
|
|
1644
|
+
|
|
1645
|
+
**Is Same Or Before Month?**
|
|
1646
|
+
|
|
1647
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by month).
|
|
1648
|
+
|
|
1649
|
+
- `other` is the *DateTime* object to compare to.
|
|
1650
|
+
|
|
1651
|
+
```javascript
|
|
1652
|
+
const isSameOrBefore = dateTime.isSameOrBeforeMonth(other);
|
|
1653
|
+
```
|
|
1654
|
+
|
|
1655
|
+
**Is Same Or Before Second?**
|
|
1656
|
+
|
|
1657
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by second).
|
|
1658
|
+
|
|
1659
|
+
- `other` is the *DateTime* object to compare to.
|
|
1660
|
+
|
|
1661
|
+
```javascript
|
|
1662
|
+
const isSameOrBefore = dateTime.isSameOrBeforeSecond(other);
|
|
1663
|
+
```
|
|
1664
|
+
|
|
1665
|
+
**Is Same Or Before Week?**
|
|
1666
|
+
|
|
1667
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by week).
|
|
1668
|
+
|
|
1669
|
+
- `other` is the *DateTime* object to compare to.
|
|
1670
|
+
|
|
1671
|
+
```javascript
|
|
1672
|
+
const isSameOrBefore = dateTime.isSameOrBeforeWeek(other);
|
|
1673
|
+
```
|
|
1674
|
+
|
|
1675
|
+
**Is Same Or Before Year?**
|
|
1676
|
+
|
|
1677
|
+
Return *true* if the *DateTime* is the same as or before another date (comparing by year).
|
|
1678
|
+
|
|
1679
|
+
- `other` is the *DateTime* object to compare to.
|
|
1680
|
+
|
|
1681
|
+
```javascript
|
|
1682
|
+
const isSameOrBefore = dateTime.isSameOrBeforeYear(other);
|
|
1683
|
+
```
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
## Utility Methods
|
|
1687
|
+
|
|
1688
|
+
**Day Name**
|
|
1689
|
+
|
|
1690
|
+
Get the name of the day of the week in current time zone and locale.
|
|
1691
|
+
|
|
1692
|
+
- `type` can be either "*long*", "*short*" or "*narrow*", and will default to "*long*" if it is not set.
|
|
1693
|
+
|
|
1694
|
+
```javascript
|
|
1695
|
+
const dayName = dateTime.dayName(type);
|
|
1696
|
+
```
|
|
1697
|
+
|
|
1698
|
+
**Day Period**
|
|
1699
|
+
|
|
1700
|
+
Get the day period in current time zone and locale.
|
|
1701
|
+
|
|
1702
|
+
- `type` can be either "*long*" or "*short*", and will default to "*long*" if it is not set.
|
|
1703
|
+
|
|
1704
|
+
```javascript
|
|
1705
|
+
const dayPeriod = dateTime.dayPeriod(type);
|
|
1706
|
+
```
|
|
1707
|
+
|
|
1708
|
+
**Days In Month**
|
|
1709
|
+
|
|
1710
|
+
Get the number of days in the current month.
|
|
1711
|
+
|
|
1712
|
+
```javascript
|
|
1713
|
+
const daysInMonth = dateTime.daysInMonth();
|
|
1714
|
+
```
|
|
1715
|
+
|
|
1716
|
+
**Days In Year**
|
|
1717
|
+
|
|
1718
|
+
Get the number of days in the current year.
|
|
1719
|
+
|
|
1720
|
+
```javascript
|
|
1721
|
+
const daysInYear = dateTime.daysInYear();
|
|
1722
|
+
```
|
|
1723
|
+
|
|
1724
|
+
**Era**
|
|
1725
|
+
|
|
1726
|
+
Get the era in current time zone and locale.
|
|
1727
|
+
|
|
1728
|
+
- `type` can be either "*long*", "*short*" or "*narrow*", and will default to "*long*" if it is not set.
|
|
1729
|
+
|
|
1730
|
+
```javascript
|
|
1731
|
+
const era = dateTime.era(type);
|
|
1732
|
+
```
|
|
1733
|
+
|
|
1734
|
+
**Is DST?**
|
|
1735
|
+
|
|
1736
|
+
Return *true* if the *DateTime* is in daylight savings.
|
|
1737
|
+
|
|
1738
|
+
```javascript
|
|
1739
|
+
const isDST = dateTime.isDST();
|
|
1740
|
+
```
|
|
1741
|
+
|
|
1742
|
+
**Is Leap Year?**
|
|
1743
|
+
|
|
1744
|
+
Return *true* if the year is a leap year.
|
|
1745
|
+
|
|
1746
|
+
```javascript
|
|
1747
|
+
const isLeapYear = dateTime.isLeapYear();
|
|
1748
|
+
```
|
|
851
1749
|
|
|
852
1750
|
**Month Name**
|
|
853
1751
|
|