@jamesrock/rockjs 1.32.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 +17 -43
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -646,56 +646,30 @@ 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
|
-
getSecondsInDay(ms) {
|
|
679
|
-
return (this.getSeconds(ms) % this.day);
|
|
680
|
-
};
|
|
681
|
-
getMinutesInDay(ms) {
|
|
682
|
-
return (this.getMinutes(ms) % this.day);
|
|
683
|
-
};
|
|
684
|
-
getHoursInDay(ms) {
|
|
685
|
-
return (this.getHours(ms) % this.day);
|
|
686
|
-
};
|
|
687
|
-
getDaysInYear(ms) {
|
|
688
|
-
return (this.getDays(ms) % this.year);
|
|
689
|
-
};
|
|
690
|
-
getMinutesInHour(ms) {
|
|
691
|
-
return floorTo(this.getMillisecondsInHour(ms) / this.minute);
|
|
692
|
-
};
|
|
693
|
-
getSecondsInMinute(ms) {
|
|
694
|
-
return floorTo(this.getMillisecondsInMinute(ms) / this.second);
|
|
695
|
-
};
|
|
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));
|
|
696
670
|
formatSeconds = (ms) => pad(this.getSecondsInMinute(ms));
|
|
697
671
|
formatMinutes = (ms) => pad(this.getMinutesInHour(ms));
|
|
698
|
-
formatHours = (ms) => pad(this.
|
|
672
|
+
formatHours = (ms) => pad(this.getHoursInDay(ms));
|
|
699
673
|
format = (ms) => `${this.formatMinutes(ms)}:${this.formatSeconds(ms)}`;
|
|
700
674
|
};
|
|
701
675
|
|