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