@jamesrock/rockjs 1.33.0 → 1.34.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/index.js +16 -45
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -646,56 +646,27 @@ export class Collection extends Array {
|
|
|
646
646
|
};
|
|
647
647
|
|
|
648
648
|
export class Time {
|
|
649
|
+
constructor(accuracy = 1) {
|
|
650
|
+
this.accuracy = accuracy;
|
|
651
|
+
};
|
|
649
652
|
second = 1000;
|
|
650
653
|
minute = (this.second * 60);
|
|
651
654
|
hour = (this.minute * 60);
|
|
652
655
|
day = (this.hour * 24);
|
|
653
656
|
year = (this.day * 365);
|
|
654
|
-
getSeconds(ms)
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return floorTo(ms / this.year);
|
|
668
|
-
};
|
|
669
|
-
getMillisecondsInHour(ms) {
|
|
670
|
-
return (ms % this.hour);
|
|
671
|
-
};
|
|
672
|
-
getMillisecondsInMinute(ms) {
|
|
673
|
-
return (ms % this.minute);
|
|
674
|
-
};
|
|
675
|
-
getMillisecondsInDay(ms) {
|
|
676
|
-
return (ms % this.day);
|
|
677
|
-
};
|
|
678
|
-
getMillisecondsInYear(ms) {
|
|
679
|
-
return (ms % this.year);
|
|
680
|
-
};
|
|
681
|
-
getSecondsInDay(ms) {
|
|
682
|
-
return this.getSeconds(this.getMillisecondsInDay(ms));
|
|
683
|
-
};
|
|
684
|
-
getMinutesInDay(ms) {
|
|
685
|
-
return this.getMinutes(this.getMillisecondsInDay(ms));
|
|
686
|
-
};
|
|
687
|
-
getHoursInDay(ms) {
|
|
688
|
-
return this.getHours(this.getMillisecondsInDay(ms));
|
|
689
|
-
};
|
|
690
|
-
getDaysInYear(ms) {
|
|
691
|
-
return this.getDays(this.getMillisecondsInYear(ms));
|
|
692
|
-
};
|
|
693
|
-
getMinutesInHour(ms) {
|
|
694
|
-
return this.getMinutes(this.getMillisecondsInHour(ms));
|
|
695
|
-
};
|
|
696
|
-
getSecondsInMinute(ms) {
|
|
697
|
-
return this.getSeconds(this.getMillisecondsInMinute(ms));
|
|
698
|
-
};
|
|
657
|
+
getSeconds = (ms) => floorTo(ms / this.second, this.accuracy);
|
|
658
|
+
getMinutes = (ms) => floorTo(ms / this.minute, this.accuracy);
|
|
659
|
+
getHours = (ms) => floorTo(ms / this.hour, this.accuracy);
|
|
660
|
+
getDays = (ms) => floorTo(ms / this.day, this.accuracy);
|
|
661
|
+
getYears = (ms) => floorTo(ms / this.year, this.accuracy);
|
|
662
|
+
getMillisecondsInMinute = (ms) => (ms % this.minute);
|
|
663
|
+
getMillisecondsInHour = (ms) => (ms % this.hour);
|
|
664
|
+
getMillisecondsInDay = (ms) => (ms % this.day);
|
|
665
|
+
getMillisecondsInYear = (ms) => (ms % this.year);
|
|
666
|
+
getHoursInDay = (ms) => this.getHours(this.getMillisecondsInDay(ms));
|
|
667
|
+
getDaysInYear = (ms) => this.getDays(this.getMillisecondsInYear(ms));
|
|
668
|
+
getMinutesInHour = (ms) => this.getMinutes(this.getMillisecondsInHour(ms));
|
|
669
|
+
getSecondsInMinute = (ms) => this.getSeconds(this.getMillisecondsInMinute(ms));
|
|
699
670
|
formatSeconds = (ms) => pad(this.getSecondsInMinute(ms));
|
|
700
671
|
formatMinutes = (ms) => pad(this.getMinutesInHour(ms));
|
|
701
672
|
formatHours = (ms) => pad(this.getHoursInDay(ms));
|