Skip to content

Commit 4fd44ea

Browse files
committed
doc(Duration): extend unit accessors documentation
* include reference to different behaviour for Durations created out of factory methods
1 parent cafc4ee commit 4fd44ea

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

src/duration.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ export default class Duration {
864864

865865
/**
866866
* Get the years.
867+
*
868+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
869+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
870+
*
871+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
867872
* @type {number}
868873
*/
869874
get years() {
@@ -872,6 +877,11 @@ export default class Duration {
872877

873878
/**
874879
* Get the quarters.
880+
*
881+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
882+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
883+
*
884+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
875885
* @type {number}
876886
*/
877887
get quarters() {
@@ -880,6 +890,11 @@ export default class Duration {
880890

881891
/**
882892
* Get the months.
893+
*
894+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
895+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
896+
*
897+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
883898
* @type {number}
884899
*/
885900
get months() {
@@ -888,6 +903,11 @@ export default class Duration {
888903

889904
/**
890905
* Get the weeks
906+
*
907+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
908+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
909+
*
910+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
891911
* @type {number}
892912
*/
893913
get weeks() {
@@ -896,6 +916,11 @@ export default class Duration {
896916

897917
/**
898918
* Get the days.
919+
*
920+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
921+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
922+
*
923+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
899924
* @type {number}
900925
*/
901926
get days() {
@@ -904,6 +929,11 @@ export default class Duration {
904929

905930
/**
906931
* Get the hours.
932+
*
933+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
934+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
935+
*
936+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
907937
* @type {number}
908938
*/
909939
get hours() {
@@ -912,6 +942,11 @@ export default class Duration {
912942

913943
/**
914944
* Get the minutes.
945+
*
946+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
947+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
948+
*
949+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
915950
* @type {number}
916951
*/
917952
get minutes() {
@@ -920,6 +955,11 @@ export default class Duration {
920955

921956
/**
922957
* Get the seconds.
958+
*
959+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
960+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
961+
*
962+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
923963
* @return {number}
924964
*/
925965
get seconds() {
@@ -928,6 +968,11 @@ export default class Duration {
928968

929969
/**
930970
* Get the milliseconds.
971+
*
972+
* Note: Durations created out of Duration.from* (e.g. fromObject) factories will always yield 0.
973+
* This will give you the correct difference in years, if the Duration was created out of a diff operation.
974+
*
975+
* More information: https://moment.github.io/luxon/#/math?id=duration-math
931976
* @return {number}
932977
*/
933978
get milliseconds() {
@@ -987,4 +1032,4 @@ export default class Duration {
9871032
}
9881033
return true;
9891034
}
990-
}
1035+
}

0 commit comments

Comments
 (0)