Custom __time period bucketing? (extended period granularity)

Has anyone considered adding the ability to bucket time in a user provided way?

What I am thinking is a lot like “period granularities”, but where a java function is provided as the truncation function.

truncate(__time) {

return truncated_time

}

I have a use case where I need to calculate the truncation for periods like P1W, P1M, P1Q, P1Y to handle “Fiscal” calendar aggregations. Fiscal calendars often don’t line up on traditional Gregorian calendar boundaries.

Any thoughts?

Thank you.

Paul