@polymarbot/shared 0.6.0 → 0.6.1

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
@@ -679,7 +679,12 @@ function generate1dSlug(timestamp, symbol) {
679
679
  const date = new Date(timestamp * 1e3);
680
680
  const month = MONTH_NAMES[date.getUTCMonth()];
681
681
  const day = date.getUTCDate();
682
- return `${prefix}-up-or-down-on-${month}-${day}`;
682
+ const YEAR_SLUG_CUTOFF = 1773532800;
683
+ if (timestamp < YEAR_SLUG_CUTOFF) {
684
+ return `${prefix}-up-or-down-on-${month}-${day}`;
685
+ }
686
+ const year = date.getUTCFullYear();
687
+ return `${prefix}-up-or-down-on-${month}-${day}-${year}`;
683
688
  }
684
689
  function calculatePeriodStartInET(intervalSeconds) {
685
690
  const now = Math.floor(Date.now() / 1e3);
@@ -724,7 +729,7 @@ function parseIntervalFromSlug(slug) {
724
729
  if (lowerSlug.match(/-up-or-down-\w+-\d+-\d+(am|pm)-et$/)) {
725
730
  return "1h" /* H1 */;
726
731
  }
727
- if (lowerSlug.match(/-up-or-down-on-\w+-\d+$/)) {
732
+ if (lowerSlug.match(/-up-or-down-on-\w+-\d+(-\d{4})?$/)) {
728
733
  return "1d" /* D1 */;
729
734
  }
730
735
  return null;
@@ -778,12 +783,12 @@ function parseTimeRangeFromSlug(slug, referenceYear) {
778
783
  }
779
784
  }
780
785
  } else if (interval === "1d" /* D1 */) {
781
- const match = lowerSlug.match(/-up-or-down-on-(\w+)-(\d+)$/);
786
+ const match = lowerSlug.match(/-up-or-down-on-(\w+)-(\d+)(?:-(\d{4}))?$/);
782
787
  if (match) {
783
- const [, monthName, day] = match;
788
+ const [, monthName, day, slugYear] = match;
784
789
  const monthIndex = MONTH_NAMES.indexOf(monthName);
785
790
  if (monthIndex !== -1) {
786
- const year = referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
791
+ const year = slugYear ? parseInt(slugYear, 10) : referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
787
792
  const utcTime = dayjs_default.utc(
788
793
  `${year}-${String(monthIndex + 1).padStart(2, "0")}-${String(day).padStart(2, "0")} 00:00:00`
789
794
  );
package/markets/utils.js CHANGED
@@ -626,7 +626,12 @@ function generate1dSlug(timestamp, symbol) {
626
626
  const date = new Date(timestamp * 1e3);
627
627
  const month = MONTH_NAMES[date.getUTCMonth()];
628
628
  const day = date.getUTCDate();
629
- return `${prefix}-up-or-down-on-${month}-${day}`;
629
+ const YEAR_SLUG_CUTOFF = 1773532800;
630
+ if (timestamp < YEAR_SLUG_CUTOFF) {
631
+ return `${prefix}-up-or-down-on-${month}-${day}`;
632
+ }
633
+ const year = date.getUTCFullYear();
634
+ return `${prefix}-up-or-down-on-${month}-${day}-${year}`;
630
635
  }
631
636
  function calculatePeriodStartInET(intervalSeconds) {
632
637
  const now = Math.floor(Date.now() / 1e3);
@@ -671,7 +676,7 @@ function parseIntervalFromSlug(slug) {
671
676
  if (lowerSlug.match(/-up-or-down-\w+-\d+-\d+(am|pm)-et$/)) {
672
677
  return "1h" /* H1 */;
673
678
  }
674
- if (lowerSlug.match(/-up-or-down-on-\w+-\d+$/)) {
679
+ if (lowerSlug.match(/-up-or-down-on-\w+-\d+(-\d{4})?$/)) {
675
680
  return "1d" /* D1 */;
676
681
  }
677
682
  return null;
@@ -725,12 +730,12 @@ function parseTimeRangeFromSlug(slug, referenceYear) {
725
730
  }
726
731
  }
727
732
  } else if (interval === "1d" /* D1 */) {
728
- const match = lowerSlug.match(/-up-or-down-on-(\w+)-(\d+)$/);
733
+ const match = lowerSlug.match(/-up-or-down-on-(\w+)-(\d+)(?:-(\d{4}))?$/);
729
734
  if (match) {
730
- const [, monthName, day] = match;
735
+ const [, monthName, day, slugYear] = match;
731
736
  const monthIndex = MONTH_NAMES.indexOf(monthName);
732
737
  if (monthIndex !== -1) {
733
- const year = referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
738
+ const year = slugYear ? parseInt(slugYear, 10) : referenceYear ?? (/* @__PURE__ */ new Date()).getFullYear();
734
739
  const utcTime = dayjs_default.utc(
735
740
  `${year}-${String(monthIndex + 1).padStart(2, "0")}-${String(day).padStart(2, "0")} 00:00:00`
736
741
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymarbot/shared",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",