github.com/antihax/goesi@v0.0.0-20240126031043-6c54d0cb7f95/helpers.go (about) 1 package goesi 2 3 import ( 4 "math" 5 "regexp" 6 "time" 7 ) 8 9 // https://community.eveonline.com/support/policies/naming-policy-en/ 10 func ValidCharacterName(name string) bool { 11 if len(name) > 37 { 12 return false 13 } 14 if m, _ := regexp.MatchString("^[\\p{L}\\d' -]+$", name); !m { 15 return false 16 } 17 return true 18 } 19 20 func FactionNameToID(faction string) int32 { 21 switch faction { 22 case "Caldari": 23 return 500001 24 case "Minmatar": 25 return 500002 26 case "Amarr": 27 return 500003 28 case "Gallente": 29 return 500004 30 } 31 return 0 32 } 33 34 func ParseTime(input int64) time.Time { 35 maxd := time.Duration(math.MaxInt64).Truncate(100 * time.Nanosecond) 36 maxdUnits := int64(maxd / 100) 37 t := time.Date(1601, 1, 1, 0, 0, 0, 0, time.UTC) 38 for input > maxdUnits { 39 t = t.Add(maxd) 40 input -= maxdUnits 41 } 42 if input != 0 { 43 t = t.Add(time.Duration(input * 100)) 44 } 45 return t 46 }