@asaleh37/ui-base 25.8.31-1 → 25.8.31-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asaleh37/ui-base",
3
- "version": "25.8.31-1",
3
+ "version": "25.8.31-2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "Ahmed Saleh Mohamed",
@@ -1,4 +1,6 @@
1
+ import moment from "moment";
1
2
  import { FormElementProps } from "../components";
3
+ import { DATE_FORMAT } from "./constants";
2
4
 
3
5
  export function hasDigitsOnly(str: string) {
4
6
  return /^\d+$/.test(str);
@@ -53,3 +55,19 @@ export function timeAgo(dateInput, appDirection: "ltr" | "rtl") {
53
55
 
54
56
  return locale === "ar" ? "الآن" : "just now";
55
57
  }
58
+
59
+ export const formatDate = (date, format) => {
60
+ if (format) {
61
+ return moment(date).format(format);
62
+ } else {
63
+ return moment(date).format(DATE_FORMAT);
64
+ }
65
+ };
66
+
67
+ export const parseStringToDate = (dateString, format) => {
68
+ if (format) {
69
+ return moment(dateString, format).toDate();
70
+ } else {
71
+ return moment(dateString, DATE_FORMAT).toDate();
72
+ }
73
+ };