MCPcopy Index your code
hub / github.com/larksuite/cli / parseTimeFlagSec

Function parseTimeFlagSec

shortcuts/task/task_util.go:174–191  ·  view source on GitHub ↗

parseTimeFlagSec parses a time flag that can be absolute (ISO 8601, timestamp) or relative (+/- Nd/w/m/h). It returns the Unix seconds string.

(input string, hint string)

Source from the content-addressed store, hash-verified

172// parseTimeFlagSec parses a time flag that can be absolute (ISO 8601, timestamp) or relative (+/- Nd/w/m/h).
173// It returns the Unix seconds string.
174func parseTimeFlagSec(input string, hint string) (string, error) {
175 if isRelativeTime(input) {
176 t, err := parseRelativeTime(input)
177 if err != nil {
178 return "", err
179 }
180 // Snap to day if unit is days or weeks
181 if strings.HasSuffix(input, "d") || strings.HasSuffix(input, "w") {
182 if hint == "end" {
183 t = time.Date(t.Year(), t.Month(), t.Day(), 23, 59, 59, 0, t.Location())
184 } else {
185 t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
186 }
187 }
188 return fmt.Sprintf("%d", t.Unix()), nil
189 }
190 return common.ParseTime(input, hint)
191}

Callers 3

parseTimeRangeMillisFunction · 0.85
parseTimeRangeRFC3339Function · 0.85

Calls 4

ParseTimeFunction · 0.92
isRelativeTimeFunction · 0.85
parseRelativeTimeFunction · 0.85
DateMethod · 0.80

Tested by

no test coverage detected