From 15b3f274405fd515aafe4897c06f91dfebc224e4 Mon Sep 17 00:00:00 2001 From: thearjunneupane Date: Sun, 31 Mar 2024 17:12:55 +0545 Subject: [PATCH] Refactored with Date struct and added Weekday Method and Tests --- nepalitime/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nepalitime/utils.go b/nepalitime/utils.go index a58c5aa..dbb5d75 100644 --- a/nepalitime/utils.go +++ b/nepalitime/utils.go @@ -17,7 +17,7 @@ func Date(year, month, day, hour, min, sec, nsec int) (*NepaliTime, error) { return nil, err } - englishTime := time.Date(englishDate[0], time.Month(englishDate[1]), englishDate[2], + englishTime := time.Date(englishDate.Year, time.Month(englishDate.Month), englishDate.Day, hour, min, sec, nsec, GetNepaliLocation()) return &NepaliTime{year, month, day, &englishTime}, nil } @@ -31,7 +31,7 @@ func FromEnglishTime(englishTime time.Time) (*NepaliTime, error) { return nil, err } - return &NepaliTime{englishDate[0], englishDate[1], englishDate[2], &englishTime}, nil + return &NepaliTime{englishDate.Year, englishDate.Month, englishDate.Day, &englishTime}, nil } // Now returns the current nepali time.