MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / getDatePrecisionFromString

Function getDatePrecisionFromString

internal/filter/datetime.go:36–71  ·  view source on GitHub ↗
(dateStr string)

Source from the content-addressed store, hash-verified

34}
35
36func getDatePrecisionFromString(dateStr string) string {
37 if strings.Contains(dateStr, ".") {
38 parts := strings.Split(dateStr, ".")
39 if len(parts) > 1 {
40 fractionalPart := parts[1]
41 fractionalPart = strings.TrimSuffix(fractionalPart, "Z")
42 if idx := strings.IndexAny(fractionalPart, "+-"); idx != -1 {
43 fractionalPart = fractionalPart[:idx]
44 }
45
46 digitCount := len(fractionalPart)
47 if digitCount >= 6 {
48 return "microseconds"
49 } else if digitCount >= 3 {
50 return "milliseconds"
51 } else if digitCount > 0 {
52 return "milliseconds"
53 }
54 }
55 }
56
57 if strings.Contains(dateStr, ":") {
58 colonCount := strings.Count(dateStr, ":")
59 if colonCount >= 2 {
60 return "second"
61 } else if colonCount == 1 {
62 return "minute"
63 }
64 }
65
66 if strings.Contains(dateStr, "T") || strings.Contains(dateStr, " ") {
67 return "hour"
68 }
69
70 return "day"
71}
72
73func getDatePrecisionFromTime(t time.Time) string {
74 if t.Nanosecond()%1000000 != 0 && t.Nanosecond()%1000 != 0 {

Callers 1

parseValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected