dce-reactkit 3.3.4 → 3.3.6

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/dist/cjs/index.js CHANGED
@@ -5632,6 +5632,54 @@ const compareArraysByProp = (a, b, prop) => {
5632
5632
  });
5633
5633
  };
5634
5634
 
5635
+ /**
5636
+ * Get current time info in local time
5637
+ * @author Gabe Abrams
5638
+ * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
5639
+ * @returns object with timestamp (ms since epoch) and numbers
5640
+ * corresponding to time values for year, month, day, hour, hour12, minute, isPM
5641
+ * where hour is in 24hr time and hour12 is in 12hr time.
5642
+ */
5643
+ const getLocalTimeInfo = (dateOrTimestamp) => {
5644
+ // Create a time string
5645
+ let d;
5646
+ if (!dateOrTimestamp) {
5647
+ // Use now
5648
+ d = new Date();
5649
+ }
5650
+ else if (typeof dateOrTimestamp === 'number') {
5651
+ // Convert to date
5652
+ d = new Date(dateOrTimestamp);
5653
+ }
5654
+ else {
5655
+ // Already a date
5656
+ d = dateOrTimestamp;
5657
+ }
5658
+ // Create all time numbers
5659
+ const timestamp = d.getTime();
5660
+ const year = d.getFullYear();
5661
+ const month = d.getMonth() + 1;
5662
+ const day = d.getDate();
5663
+ const hour = d.getHours();
5664
+ const isPM = hour >= 12;
5665
+ let hour12 = hour % 12;
5666
+ if (hour12 === 0) {
5667
+ hour12 = 12;
5668
+ }
5669
+ const minute = d.getMinutes();
5670
+ // Return
5671
+ return {
5672
+ timestamp,
5673
+ year,
5674
+ month,
5675
+ day,
5676
+ hour,
5677
+ hour12,
5678
+ isPM,
5679
+ minute,
5680
+ };
5681
+ };
5682
+
5635
5683
  /**
5636
5684
  * Days of the week
5637
5685
  * @author Gabe Abrams
@@ -5695,6 +5743,7 @@ exports.forceNumIntoBounds = forceNumIntoBounds;
5695
5743
  exports.genCSV = genCSV;
5696
5744
  exports.genRouteHandler = genRouteHandler;
5697
5745
  exports.getHumanReadableDate = getHumanReadableDate;
5746
+ exports.getLocalTimeInfo = getLocalTimeInfo;
5698
5747
  exports.getMonthName = getMonthName;
5699
5748
  exports.getOrdinal = getOrdinal;
5700
5749
  exports.getPartOfDay = getPartOfDay;