MCPcopy
hub / github.com/benbjohnson/litestream / parseTimeValue

Function parseTimeValue

vfs.go:2306–2329  ·  view source on GitHub ↗

parseTimeValue parses a timestamp string, trying RFC3339 first, then relative expressions.

(value string)

Source from the content-addressed store, hash-verified

2304
2305// parseTimeValue parses a timestamp string, trying RFC3339 first, then relative expressions.
2306func parseTimeValue(value string) (time.Time, error) {
2307 // Try RFC3339Nano first (existing behavior)
2308 if t, err := time.Parse(time.RFC3339Nano, value); err == nil {
2309 return t, nil
2310 }
2311
2312 // Try RFC3339 (without nanoseconds)
2313 if t, err := time.Parse(time.RFC3339, value); err == nil {
2314 return t, nil
2315 }
2316
2317 // Fall back to dateparser for relative expressions
2318 cfg := &dateparser.Configuration{
2319 CurrentTime: time.Now().UTC(),
2320 }
2321 result, err := dateparser.Parse(cfg, value)
2322 if err != nil {
2323 return time.Time{}, fmt.Errorf("invalid timestamp (expected RFC3339 or relative time like '5 minutes ago'): %s", value)
2324 }
2325 if result.Time.IsZero() {
2326 return time.Time{}, fmt.Errorf("could not parse time: %s", value)
2327 }
2328 return result.Time.UTC(), nil
2329}
2330
2331// FileControl handles file control operations, specifically PRAGMA commands for time travel.
2332func (f *VFSFile) FileControl(op int, pragmaName string, pragmaValue *string) (*string, error) {

Callers 2

FileControlMethod · 0.85
SetVFSConnectionTimeFunction · 0.85

Calls 1

IsZeroMethod · 0.80

Tested by

no test coverage detected