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:
Winni Neessen 2023-06-27 16:12:06 +02:00
parent a0b67b0367
commit 4318599eb0
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -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}
}