- Dharmagya
- panchang docs
- Upgrading 5.2 → 5.3
Upgrading 5.2 → 5.3
panchang · v5.4.0 · MIT
A version bump for TypeScript and nothing else. For Go: the new types package and the aliases that keep old code compiling, the Context twins on the range-walking calls, the enum helpers, and a way to match an error code.
5.3 is the first release where the two languages did different things. The npm package is a version bump and nothing else. The Go module gains a package, fourteen methods, forty-one helpers and a way to match an error. Nothing is removed, renamed or retyped in either.
TypeScript: nothing changed
The published 5.3.0 tarball is byte-identical to 5.2.1 in every shipped file except the version field in package.json. Same exports, same types, same arithmetic, same strings. There is no migration to perform and nothing to re-pin.
npm install panchang-ts@5.3.0Upgrade it when you upgrade everything else. If you are coming from 5.1 or earlier, the output does change — see Upgrading 5.1 → 5.2, which is where the festival, eclipse and Shadbala differences live.
Go: data types moved to their own package
panchang now holds the engine — New, the Session methods, the standalone calculations. The new types package holds every data type they take and return: the results, the option structs, the enums and the error type. A caller normally imports both.
import (
"github.com/ishankgupta95/panchang/source/go/v5/panchang"
"github.com/ishankgupta95/panchang/source/go/v5/types"
)
s := panchang.New()
pune := types.GeoLocation{Latitude: 18.52, Longitude: 73.86}
day, ok, err := s.GetDailyPanchang(when, pune, types.PanchangOptions{
Timezone: panchang.OffsetMinutes(330),
})Your existing code still compiles. The old spellings survive in panchang as type aliases — ninety-seven of them. Session is now the only type the package declares of its own. An alias is the same type, so the two spellings interoperate freely and you can migrate a file at a time, or never.
| Was | Now | Old spelling |
|---|---|---|
panchang.GeoLocation | types.GeoLocation | Kept |
panchang.Options | types.PanchangOptions | Kept |
panchang.Error | types.PanchangError | Kept |
panchang.Reference | types.Reference | Kept |
Note that the option struct gained a word on the way across: panchang.Options is an alias for types.PanchangOptions, not for types.Options, which does not exist.
Fourteen methods gained a Context twin
Every operation that walks a range of dates now has a twin ending in Context that takes a context.Context first and stops early once it is cancelled or its deadline passes. The plain form is unchanged and runs to completion.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
fest, err := s.ComputeFestivalsForYearContext(ctx, 2026, pune,
types.YearlyListingOptions{Timezone: panchang.OffsetMinutes(330)})
// 259 festivals for Pune in 2026 (253 from 5.4.0)The twins cover the four Build*Table builders and the ten Compute*ForYear and Compute*InRange listings — the calls that can run for seconds on a wide window. A single day never needed one.
Reach for a twin when the work is behind a request or a cancellable job. Everywhere else the plain form stays the shorter call. See Performance for what these operations actually cost.
Matching an error code
The Err* constants are types.ErrorCode values rather than errors, so errors.Is cannot take one directly. panchang.IsCode is the matching form to reach for.
_, _, err := s.GetDailyPanchang(when, types.GeoLocation{Latitude: 91}, opts)
panchang.IsCode(err, types.ErrInvalidLatitude) // true
var pe *types.PanchangError // still works
if errors.As(err, &pe) {
_ = pe.Code // "INVALID_LATITUDE"
}There are also four errors.Is targets for the conditions you are most likely to branch on — types.ErrNoSunriseSentinel, ErrNoSunsetSentinel, ErrCircumpolarSentinel and ErrPlacidusDivergedSentinel. A PanchangError matches a sentinel on code, and operations never return a sentinel itself: you get a fresh error whose message names the location and the window it searched.
The code set itself is unchanged — still the same fourteen, still enumerable with panchang.AllErrorCodes(). See Errors & Compatibility.
Forty-one enum helpers
Each enum now has an All function returning every member, for the switch you want the compiler to keep honest and for populating a picker.
panchang.AllGrahas() // 9
panchang.AllLanguages() // 2
panchang.AllErrorCodes() // 14The full list is on Types & Exports. They are Go-side only; in TypeScript the union type already gives you exhaustiveness at compile time, which is what these recover for Go.
What to do
- TypeScript: bump the version. Nothing else. No rebuild, no re-pin, no diff.
- Go: bump the version. Your code compiles unchanged, because the old type names are aliases.
- Then, at your own pace, import
typesand name data types from it. New code reads better for it; old code is not wrong. - Switch error matching to
panchang.IsCodeif you were reaching forerrors.Asonly to read a code. - Pass a context to the long listings that run behind a request.
