@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.
Files changed (2) hide show
  1. package/index.js +16 -45
  2. 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
- return floorTo(ms / this.second);
656
- };
657
- getMinutes(ms) {
658
- return floorTo(ms / this.minute);
659
- };
660
- getHours(ms) {
661
- return floorTo(ms / this.hour);
662
- };
663
- getDays(ms) {
664
- return floorTo(ms / this.day);
665
- };
666
- getYears(ms) {
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));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamesrock/rockjs",
3
- "version": "1.33.0",
3
+ "version": "1.34.0",
4
4
  "description": "utility bliss",
5
5
  "license": "ISC",
6
6
  "author": "James Rock",