@rkmodules/rules 0.0.125 → 0.0.126

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,24 +2506,83 @@ 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) {
2512
2517
  return [2 /*return*/, {
2513
- string: mapTree(inputs.date || {}, function (dateInput) {
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 new Date()
2580
+ .toLocaleString("sv", {
2581
+ timeZone: params.timezone,
2582
+ timeZoneName: "longOffset",
2583
+ })
2584
+ .replace(" ", "T")
2585
+ .replace(" GMT", "");
2527
2586
  }),
2528
2587
  }];
2529
2588
  });