dce-reactkit 3.3.3-beta.2 → 3.3.5

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
@@ -1303,9 +1303,10 @@ const getOrdinal = (num) => {
1303
1303
  * Get current time info in US Boston Eastern Time, independent of machine
1304
1304
  * timezone
1305
1305
  * @author Gabe Abrams
1306
- * @param [date=now] the date to get info on or a ms since epoch timestamp
1306
+ * @param [dateOrTimestamp=now] the date to get info on or a ms since epoch timestamp
1307
1307
  * @returns object with timestamp (ms since epoch) and numbers
1308
- * corresponding to ET time values for year, month, day, hour, minute
1308
+ * corresponding to ET time values for year, month, day, hour, hour12, minute, isPM
1309
+ * where hour is in 24hr time and hour12 is in 12hr time.
1309
1310
  */
1310
1311
  const getTimeInfoInET = (dateOrTimestamp) => {
1311
1312
  // Create a time string
@@ -1335,14 +1336,15 @@ const getTimeInfoInET = (dateOrTimestamp) => {
1335
1336
  const month = Number.parseInt(monthStr, 10);
1336
1337
  const day = Number.parseInt(dayStr, 10);
1337
1338
  const minute = Number.parseInt(minStr, 10);
1338
- let hour = Number.parseInt(hourStr, 10);
1339
+ let hour12 = Number.parseInt(hourStr, 10);
1339
1340
  // Convert from am/pm to 24hr
1340
1341
  const isAM = ending.toLowerCase().includes('am');
1341
1342
  const isPM = !isAM;
1342
- if (isPM && hour !== 12) {
1343
+ let hour = hour12;
1344
+ if (isPM && hour12 !== 12) {
1343
1345
  hour += 12;
1344
1346
  }
1345
- else if (isAM && hour === 12) {
1347
+ else if (isAM && hour12 === 12) {
1346
1348
  hour = 0;
1347
1349
  }
1348
1350
  // Return
@@ -1352,6 +1354,8 @@ const getTimeInfoInET = (dateOrTimestamp) => {
1352
1354
  month,
1353
1355
  day,
1354
1356
  hour,
1357
+ hour12,
1358
+ isPM,
1355
1359
  minute,
1356
1360
  };
1357
1361
  };
@@ -5628,6 +5632,51 @@ const compareArraysByProp = (a, b, prop) => {
5628
5632
  });
5629
5633
  };
5630
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
+ const hour12 = hour % 12;
5666
+ const minute = d.getMinutes();
5667
+ // Return
5668
+ return {
5669
+ timestamp,
5670
+ year,
5671
+ month,
5672
+ day,
5673
+ hour,
5674
+ hour12,
5675
+ isPM,
5676
+ minute,
5677
+ };
5678
+ };
5679
+
5631
5680
  /**
5632
5681
  * Days of the week
5633
5682
  * @author Gabe Abrams
@@ -5691,6 +5740,7 @@ exports.forceNumIntoBounds = forceNumIntoBounds;
5691
5740
  exports.genCSV = genCSV;
5692
5741
  exports.genRouteHandler = genRouteHandler;
5693
5742
  exports.getHumanReadableDate = getHumanReadableDate;
5743
+ exports.getLocalTimeInfo = getLocalTimeInfo;
5694
5744
  exports.getMonthName = getMonthName;
5695
5745
  exports.getOrdinal = getOrdinal;
5696
5746
  exports.getPartOfDay = getPartOfDay;