Browse Source

new:1.chis更新GetAgeFromIdCard,因为部分地区必须生日过了65岁.

QiuSW 1 năm trước cách đây
mục cha
commit
b8eb14dd74
4 tập tin đã thay đổi với 36 bổ sung5 xóa
  1. 3 3
      chis/record.go
  2. 31 0
      gdate/convert_datetime.go
  3. 1 1
      gdate/xdate.go
  4. 1 1
      win/shortcut.go

+ 3 - 3
chis/record.go

@@ -7,7 +7,7 @@ import (
 	"gbase/glog"
 )
 
-func GetAgeFromIdCard(idCard string) (age int) {
+func GetAgeFromIdCard(idCard string, increment int) (age int) {
 	age = 0
 	if len(idCard) != 18 {
 		return age
@@ -28,9 +28,9 @@ func GetAgeFromIdCard(idCard string) (age int) {
 	firstDayOfNextYear := time.Date(today.Year()+1, 1, 1, 0, 0, 0, 0, time.UTC)
 	lastDayOfYear := firstDayOfNextYear.AddDate(0, 0, -1)
 	if lastDayOfYear.Month() > birthday.Month() {
-		age += 1
+		age += increment
 	} else if lastDayOfYear.Month() == birthday.Month() && lastDayOfYear.Day() > birthday.Day() {
-		age += 1
+		age += increment
 	} else {
 		age += 0
 	}

+ 31 - 0
gdate/convert_datetime.go

@@ -0,0 +1,31 @@
+package gdate
+
+import (
+	"fmt"
+	"gbase/glog"
+	"strconv"
+	"time"
+)
+
+func ConvertTimestampToDatetime(ts string) (date string) {
+
+	// 将字符串转换为整数,时间戳单位是毫秒
+	timestamp, err := strconv.ParseInt(ts, 10, 64)
+	if err != nil {
+		glog.XWarning(fmt.Sprintf("strconv.ParseInt ts error : %v", err))
+		return
+	}
+	if len(ts) <= 10 {
+		timestamp = timestamp * int64(time.Second)
+	} else {
+		// 将毫秒时间戳转换为纳秒时间戳
+		timestamp = timestamp * int64(time.Millisecond)
+	}
+
+	// 将时间戳转换为time.Time类型
+	t := time.Unix(0, timestamp)
+
+	// 格式化时间为字符串
+	timeStr := t.Format("2006-01-02 15:04:05")
+	return timeStr
+}

+ 1 - 1
datetime/xdate.go → gdate/xdate.go

@@ -1,4 +1,4 @@
-package datetime
+package gdate
 
 import "time"
 

+ 1 - 1
win/shortcut.go

@@ -9,7 +9,7 @@ import (
 	"strings"
 )
 
-func CreateShortCut(softPath, shortcutName string) (err error) {
+func CreateSoftwareLnk(softPath, shortcutName string) (err error) {
 	startUpFlag := false
 	userHomeDir, _ := os.UserConfigDir()
 	startUpList := []string{