mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
23 lines
349 B
Go
23 lines
349 B
Go
package timeutil
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func YearMonthDiff(t1, t2 time.Time) (years, months int) {
|
|
t2 = t2.AddDate(0, 0, 1) // advance t2 to make the range inclusive
|
|
years = 0
|
|
for t1.AddDate(years, 0, 0).Before(t2) {
|
|
years++
|
|
}
|
|
years--
|
|
|
|
months = 0
|
|
for t1.AddDate(years, months, 0).Before(t2) {
|
|
months++
|
|
}
|
|
months--
|
|
|
|
return years, months
|
|
}
|