Skip to content

feat: add timeRound template function - #492

Open
AdamMagued wants to merge 1 commit into
Masterminds:masterfrom
AdamMagued:feat-add-time-round
Open

AdamMagued wants to merge 1 commit into
Masterminds:masterfrom
AdamMagued:feat-add-time-round

Conversation

@AdamMagued

Copy link
Copy Markdown

Summary

Adds the timeRound template function to round dates and timestamps to the nearest duration multiple using Go standard library time.Time.Round(d).

Details

  • Implements timeRound(duration interface{}, date interface{}) (time.Time, error) in date.go.
  • Supports duration inputs as string (parsed via time.ParseDuration), time.Duration, or convertible types via cast.ToDurationE.
  • Supports date inputs as time.Time or string / timestamp representations parsed via cast.ToTimeE.
  • Registers "timeRound" and "time_round" in GenericFuncMap() in functions.go.
  • Documents timeRound with usage examples in docs/date.md.
  • Adds regression unit tests in date_test.go verifying rounding to 15m, 1h, pointer handling, direct invocations, template pipeline execution, and error handling for invalid duration and date inputs.

Fixes #471

Implement timeRound to round timestamps to the nearest duration interval.
Supports duration as string or time.Duration, and date as time.Time or string.
Registers timeRound and time_round in GenericFuncMap, adds unit tests, and
updates documentation.

Fixes Masterminds#471

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant