@polymarbot/shared 0.6.1 → 0.6.2

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/markets/utils.cjs CHANGED
@@ -636,6 +636,8 @@ var SYMBOL_FULL_NAME_MAP = {
636
636
  ["btc" /* BTC */]: "bitcoin",
637
637
  ["sol" /* SOL */]: "solana"
638
638
  };
639
+ var YEAR_SLUG_CUTOFF_1H = 1773550800;
640
+ var YEAR_SLUG_CUTOFF_1D = 1773532800;
639
641
  var MONTH_NAMES = [
640
642
  "january",
641
643
  "february",
@@ -668,7 +670,11 @@ function generate1hSlug(timestamp, symbol) {
668
670
  const day = etTime.date();
669
671
  const hour = etTime.format("h");
670
672
  const ampm = etTime.format("a");
671
- return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
673
+ if (timestamp < YEAR_SLUG_CUTOFF_1H) {
674
+ return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
675
+ }
676
+ const year = etTime.year();
677
+ return `${prefix}-up-or-down-${month}-${day}-${year}-${hour}${ampm}-et`;
672
678
  }
673
679
  function generate4hSlug(timestamp, symbol) {
674
680
  const prefix = symbol.toLowerCase();
@@ -679,8 +685,7 @@ function generate1dSlug(timestamp, symbol) {
679
685
  const date = new Date(timestamp * 1e3);
680
686
  const month = MONTH_NAMES[date.getUTCMonth()];
681
687
  const day = date.getUTCDate();
682
- const YEAR_SLUG_CUTOFF = 1773532800;
683
- if (timestamp < YEAR_SLUG_CUTOFF) {
688
+ if (timestamp < YEAR_SLUG_CUTOFF_1D) {
684
689
  return `${prefix}-up-or-down-on-${month}-${day}`;
685
690
  }
686
691
  const year = date.getUTCFullYear();
@@ -726,7 +731,7 @@ function parseIntervalFromSlug(slug) {
726
731
  if (lowerSlug.includes("-updown-4h-")) {
727
732
  return "4h" /* H4 */;
728
733
  }
729
- if (lowerSlug.match(/-up-or-down-\w+-\d+-\d+(am|pm)-et$/)) {
734
+ if (lowerSlug.match(/-up-or-down-\w+-\d+(-\d{4})?-\d+(am|pm)-et$/)) {
730
735
  return "1h" /* H1 */;
731
736
  }
732
737
  if (lowerSlug.match(/-up-or-down-on-\w+-\d+(-\d{4})?$/)) {
@@ -763,12 +768,12 @@ function parseTimeRangeFromSlug(slug, referenceYear) {
763
768
  startTime = parseInt(match[1], 10);
764
769
  }
765
770
  } else if (interval === "1h" /* H1 */) {
766
- const match = lowerSlug.match(/-up-or-down-(\w+)-(\d+)-(\d+)(am|pm)-et$/);
771
+ const match = lowerSlug.match(/-up-or-down-(\w+)-(\d+)(?:-(\d{4}))?-(\d+)(am|pm)-et$/);
767
772
  if (match) {
768
- const [, monthName, day, hour, ampm] = match;
773
+ const [, monthName, day, slugYear, hour, ampm] = match;
769
774
  const monthIndex = MONTH_NAMES.indexOf(monthName);
770
775
  if (monthIndex !== -1) {
771
- const year = referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
776
+ const year = slugYear ? parseInt(slugYear, 10) : referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
772
777
  let hour24 = parseInt(hour, 10);
773
778
  if (ampm === "pm" && hour24 !== 12) {
774
779
  hour24 += 12;
package/markets/utils.js CHANGED
@@ -583,6 +583,8 @@ var SYMBOL_FULL_NAME_MAP = {
583
583
  ["btc" /* BTC */]: "bitcoin",
584
584
  ["sol" /* SOL */]: "solana"
585
585
  };
586
+ var YEAR_SLUG_CUTOFF_1H = 1773550800;
587
+ var YEAR_SLUG_CUTOFF_1D = 1773532800;
586
588
  var MONTH_NAMES = [
587
589
  "january",
588
590
  "february",
@@ -615,7 +617,11 @@ function generate1hSlug(timestamp, symbol) {
615
617
  const day = etTime.date();
616
618
  const hour = etTime.format("h");
617
619
  const ampm = etTime.format("a");
618
- return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
620
+ if (timestamp < YEAR_SLUG_CUTOFF_1H) {
621
+ return `${prefix}-up-or-down-${month}-${day}-${hour}${ampm}-et`;
622
+ }
623
+ const year = etTime.year();
624
+ return `${prefix}-up-or-down-${month}-${day}-${year}-${hour}${ampm}-et`;
619
625
  }
620
626
  function generate4hSlug(timestamp, symbol) {
621
627
  const prefix = symbol.toLowerCase();
@@ -626,8 +632,7 @@ function generate1dSlug(timestamp, symbol) {
626
632
  const date = new Date(timestamp * 1e3);
627
633
  const month = MONTH_NAMES[date.getUTCMonth()];
628
634
  const day = date.getUTCDate();
629
- const YEAR_SLUG_CUTOFF = 1773532800;
630
- if (timestamp < YEAR_SLUG_CUTOFF) {
635
+ if (timestamp < YEAR_SLUG_CUTOFF_1D) {
631
636
  return `${prefix}-up-or-down-on-${month}-${day}`;
632
637
  }
633
638
  const year = date.getUTCFullYear();
@@ -673,7 +678,7 @@ function parseIntervalFromSlug(slug) {
673
678
  if (lowerSlug.includes("-updown-4h-")) {
674
679
  return "4h" /* H4 */;
675
680
  }
676
- if (lowerSlug.match(/-up-or-down-\w+-\d+-\d+(am|pm)-et$/)) {
681
+ if (lowerSlug.match(/-up-or-down-\w+-\d+(-\d{4})?-\d+(am|pm)-et$/)) {
677
682
  return "1h" /* H1 */;
678
683
  }
679
684
  if (lowerSlug.match(/-up-or-down-on-\w+-\d+(-\d{4})?$/)) {
@@ -710,12 +715,12 @@ function parseTimeRangeFromSlug(slug, referenceYear) {
710
715
  startTime = parseInt(match[1], 10);
711
716
  }
712
717
  } else if (interval === "1h" /* H1 */) {
713
- const match = lowerSlug.match(/-up-or-down-(\w+)-(\d+)-(\d+)(am|pm)-et$/);
718
+ const match = lowerSlug.match(/-up-or-down-(\w+)-(\d+)(?:-(\d{4}))?-(\d+)(am|pm)-et$/);
714
719
  if (match) {
715
- const [, monthName, day, hour, ampm] = match;
720
+ const [, monthName, day, slugYear, hour, ampm] = match;
716
721
  const monthIndex = MONTH_NAMES.indexOf(monthName);
717
722
  if (monthIndex !== -1) {
718
- const year = referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
723
+ const year = slugYear ? parseInt(slugYear, 10) : referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
719
724
  let hour24 = parseInt(hour, 10);
720
725
  if (ampm === "pm" && hour24 !== 12) {
721
726
  hour24 += 12;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymarbot/shared",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",