From faf1d3cc35a3a5f83558946c8056537a4d77fa1f Mon Sep 17 00:00:00 2001
From: liuleilei <234@qq.com>
Date: 星期一, 11 九月 2023 09:34:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 minipro_standard/util/utils.js |   62 +++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/minipro_standard/util/utils.js b/minipro_standard/util/utils.js
new file mode 100644
index 0000000..f30d0dc
--- /dev/null
+++ b/minipro_standard/util/utils.js
@@ -0,0 +1,62 @@
+/***
+ *
+ * @param time 鏃ユ湡 骞存湀鏃�
+ */
+const gsdate = (time) => {
+    let date = new Date(time)
+    let y = date.getFullYear()
+    let m = date.getMonth() + 1
+    m = m < 10 ? ('0' + m) : m
+    let d = date.getDate()
+    d = d < 10 ? ('0' + d) : d
+    return y + '-' + m + '-' + d;
+}
+
+/***
+ *
+ * @param time 鏃ユ湡 骞存湀鏃ユ椂鍒嗙
+ * @param Sign 闂撮殧
+ */
+function setTime (time, Sign) {
+    let year = time.getFullYear();
+    let month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : `0${time.getMonth() + 1}`;
+    let day = time.getDate() >= 10 ? time.getDate() : `0${time.getDate()}`;
+    let hour = time.getHours() >= 10 ? time.getHours() : `0${time.getHours()}`;
+    let minute = time.getMinutes() >= 10 ? time.getMinutes() : `0${time.getMinutes()}`;
+    let second = time.getSeconds() >= 10 ? time.getSeconds() : `0${time.getSeconds()}`;
+    return [year, Sign, month , Sign, day, ' ', hour , ':', minute, ':', second ].join('');
+}
+
+/***
+ *
+ * @param time 鏃ユ湡 骞存湀鏃ユ椂鍒嗙
+ * @param Sign 闂撮殧
+ */
+function setTimeO (time, Sign) {
+    let year = time.getFullYear();
+    let month = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : `0${time.getMonth() + 1}`;
+    let day = time.getDate() >= 10 ? time.getDate() : `0${time.getDate()}`;
+    let hour = time.getHours() >= 10 ? time.getHours() : `0${time.getHours()}`;
+    let minute = time.getMinutes() >= 10 ? time.getMinutes() : `0${time.getMinutes()}`;
+    let second = time.getSeconds() >= 10 ? time.getSeconds() : `0${time.getSeconds()}`;
+    return [year, Sign, month , Sign, day, ' ', hour , ':', minute, ':', '00' ].join('');
+}
+
+/***
+ * phoneRegular: 鎵嬫満鍙烽獙璇�
+ * mailboxRegular: 閭楠岃瘉
+ * positiveInteger: 姝f暣鏁�
+ * decimal: 灏忔暟锛堝彧鏀寔鍥涗綅灏忔暟锛�
+ * positiveIntegerDecimal: 姝f暣鏁板皬鏁帮紙鏈�澶氬洓浣嶅皬鏁帮級
+ * number锛氭暟瀛楁渶澶氫繚鐣欏洓浣嶅皬鏁�
+ */
+const REGULAR = {
+    phoneRegular: /^1[3456789]\d{9}$/,
+    mailboxRegular: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
+    positiveInteger: /^[0-9]*[1-9][0-9]*$/,
+    decimal: /^0$|^[1-9]\d{0,15}$|^[1-9]\d{0,15}\.{1}\d{1,4}$|^0\.{1}\d{1,4}$/g,
+    positiveIntegerDecimal: /^([1-9][0-9]*|0)(\.[0-9]?[1-9][1-9][1-9])?$/,
+    number: /^\d+(?:\.\d{1,4})?$/
+}
+
+export { gsdate, setTime, setTimeO, REGULAR }

--
Gitblit v1.9.3