Replace hardcoded date format with constant
Replace the hardcoded "2006-01-02" date format with the DateFormat constant in both SunsetByDateString and SunriseByDateString functions to ensure consistency and easier future updates.
This commit is contained in:
parent
a0b67b0367
commit
4318599eb0
|
@ -140,7 +140,7 @@ func (a *AstronomicalInfo) Sunset() DateTime {
|
|||
// available in the AstronomicalInfo it will return DateTime in
|
||||
// which the "not available" field will be true.
|
||||
func (a *AstronomicalInfo) SunsetByDateString(ds string) DateTime {
|
||||
t, err := time.Parse("2006-01-02", ds)
|
||||
t, err := time.Parse(DateFormat, ds)
|
||||
if err != nil {
|
||||
return DateTime{na: true}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ func (a *AstronomicalInfo) Sunrise() DateTime {
|
|||
// available in the AstronomicalInfo it will return DateTime in
|
||||
// which the "not available" field will be true.
|
||||
func (a *AstronomicalInfo) SunriseByDateString(ds string) DateTime {
|
||||
t, err := time.Parse("2006-01-02", ds)
|
||||
t, err := time.Parse(DateFormat, ds)
|
||||
if err != nil {
|
||||
return DateTime{na: true}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue