mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'feat/BE/US-35/stock-transfer' into 'development-before-sso'
(BE-58,,59): extend db schema & build stock transfer api See merge request mbugroup/lti-api!19
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"time"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// ParseDateString mengubah string "YYYY-MM-DD" menjadi time.Time
|
||||
func ParseDateString(dateStr string) (time.Time, error) {
|
||||
if dateStr == "" {
|
||||
return time.Time{}, errors.New("date string is empty")
|
||||
}
|
||||
|
||||
parsed, err := time.Parse("2006-01-02", dateStr)
|
||||
if err != nil {
|
||||
return time.Time{}, errors.New("invalid date format, expected YYYY-MM-DD")
|
||||
}
|
||||
|
||||
return parsed, nil
|
||||
}
|
||||
|
||||
// FormatDate mengubah time.Time menjadi string "YYYY-MM-DD"
|
||||
func FormatDate(t time.Time) string {
|
||||
return t.Format("2006-01-02")
|
||||
}
|
||||
Reference in New Issue
Block a user