@rkmodules/rules 0.0.125 → 0.0.128

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/index.cjs.js CHANGED
@@ -2508,6 +2508,11 @@ var formatDate = {
2508
2508
  },
2509
2509
  outputs: {
2510
2510
  string: "string",
2511
+ localDate: "string",
2512
+ localTime: "string",
2513
+ localIsoDate: "string",
2514
+ localIsoTime: "string",
2515
+ localIso: "string",
2511
2516
  },
2512
2517
  impl: function (inputs, params, engine) { return __awaiter(void 0, void 0, void 0, function () {
2513
2518
  return __generator(this, function (_a) {
@@ -2515,17 +2520,71 @@ var formatDate = {
2515
2520
  string: mapTree(inputs.date || {}, function (dateInput) {
2516
2521
  var parsedDate = new Date(dateInput || Date.now());
2517
2522
  if (isNaN(parsedDate.getTime())) {
2518
- return "invalid date";
2523
+ return [];
2519
2524
  }
2520
2525
  var dateStyle = params.dateStyle === "none" ? undefined : params.dateStyle;
2521
2526
  var timeStyle = params.timeStyle === "none" ? undefined : params.timeStyle;
2522
- var str = new Intl.DateTimeFormat(params.locale, {
2527
+ return new Intl.DateTimeFormat(params.locale, {
2523
2528
  dateStyle: dateStyle,
2524
2529
  timeStyle: timeStyle,
2525
2530
  hour12: params.hour12,
2526
2531
  timeZone: params.timezone,
2527
2532
  }).format(parsedDate);
2528
- return str;
2533
+ }),
2534
+ localDate: mapTree(inputs.date || {}, function (dateInput) {
2535
+ var parsedDate = new Date(dateInput || Date.now());
2536
+ if (isNaN(parsedDate.getTime())) {
2537
+ return "invalid date";
2538
+ }
2539
+ var dateStyle = params.dateStyle === "none" ? undefined : params.dateStyle;
2540
+ return new Intl.DateTimeFormat(params.locale, {
2541
+ dateStyle: dateStyle,
2542
+ timeZone: params.timezone,
2543
+ }).format(parsedDate);
2544
+ }),
2545
+ localTime: mapTree(inputs.date || {}, function (dateInput) {
2546
+ var parsedDate = new Date(dateInput || Date.now());
2547
+ if (isNaN(parsedDate.getTime())) {
2548
+ return "invalid date";
2549
+ }
2550
+ var timeStyle = params.timeStyle === "none" ? undefined : params.timeStyle;
2551
+ return new Intl.DateTimeFormat(params.locale, {
2552
+ timeStyle: timeStyle,
2553
+ hour12: params.hour12,
2554
+ timeZone: params.timezone,
2555
+ }).format(parsedDate);
2556
+ }),
2557
+ localIsoDate: mapTree(inputs.date || {}, function (dateInput) {
2558
+ var parsedDate = new Date(dateInput || Date.now());
2559
+ if (isNaN(parsedDate.getTime())) {
2560
+ return "invalid date";
2561
+ }
2562
+ return parsedDate.toLocaleDateString("sv", {
2563
+ timeZone: params.timezone,
2564
+ dateStyle: "short",
2565
+ });
2566
+ }),
2567
+ localIsoTime: mapTree(inputs.date || {}, function (dateInput) {
2568
+ var parsedDate = new Date(dateInput || Date.now());
2569
+ if (isNaN(parsedDate.getTime())) {
2570
+ return "invalid date";
2571
+ }
2572
+ return parsedDate.toLocaleTimeString("sv", {
2573
+ timeZone: params.timezone,
2574
+ });
2575
+ }),
2576
+ localIso: mapTree(inputs.date || {}, function (dateInput) {
2577
+ var parsedDate = new Date(dateInput || Date.now());
2578
+ if (isNaN(parsedDate.getTime())) {
2579
+ return "invalid date";
2580
+ }
2581
+ return parsedDate
2582
+ .toLocaleString("sv", {
2583
+ timeZone: params.timezone,
2584
+ timeZoneName: "longOffset",
2585
+ })
2586
+ .replace(" ", "T")
2587
+ .replace(" GMT", "");
2529
2588
  }),
2530
2589
  }];
2531
2590
  });
@@ -2594,7 +2653,40 @@ var isoDate = {
2594
2653
  }); },
2595
2654
  };
2596
2655
 
2656
+ var today = {
2657
+ name: "today",
2658
+ label: "Today",
2659
+ description: "The date of today",
2660
+ inputs: {},
2661
+ outputs: {
2662
+ iso: "string",
2663
+ date: "string",
2664
+ time: "string",
2665
+ },
2666
+ impl: function (inputs, params, engine) { return __awaiter(void 0, void 0, void 0, function () {
2667
+ return __generator(this, function (_a) {
2668
+ return [2 /*return*/, {
2669
+ date: broadCast(new Date().toLocaleDateString("sv", {
2670
+ timeZone: params.timezone,
2671
+ dateStyle: "short",
2672
+ })),
2673
+ time: broadCast(new Date().toLocaleTimeString("sv", {
2674
+ timeZone: params.timezone,
2675
+ })),
2676
+ iso: broadCast(new Date()
2677
+ .toLocaleString("sv", {
2678
+ timeZone: params.timezone,
2679
+ timeZoneName: "longOffset",
2680
+ })
2681
+ .replace(" ", "T")
2682
+ .replace(" GMT", "")),
2683
+ }];
2684
+ });
2685
+ }); },
2686
+ };
2687
+
2597
2688
  var functions = {
2689
+ today: today,
2598
2690
  parseDate: parseDate,
2599
2691
  formatDate: formatDate,
2600
2692
  isoDate: isoDate,