feat: add progressive Eino examples and unify weather provider
This commit is contained in:
1 parent
73f6f0901e
commit
1373f0903f
18 files changed
+893
-380
No files matched your search
@@ -16,9 +16,17 @@ import (
|
||||
|
||||
func forecastDates(args model.WeatherArguments, now time.Time) (time.Time, time.Time, error) {
|
||||
zone := time.FixedZone("Asia/Shanghai", 8*60*60)
|
||||
start, err := time.ParseInLocation(time.DateOnly, args.StartDate, zone)
|
||||
if err != nil {
|
||||
return time.Time{}, time.Time{}, fmt.Errorf("start_date 必须是 YYYY-MM-DD 格式的有效日期")
|
||||
now = now.In(zone)
|
||||
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, zone)
|
||||
start := today
|
||||
var err error
|
||||
if args.StartDate != "" {
|
||||
start, err = time.ParseInLocation(time.DateOnly, args.StartDate, zone)
|
||||
if err != nil {
|
||||
return time.Time{}, time.Time{}, fmt.Errorf("start_date 必须是 YYYY-MM-DD 格式的有效日期")
|
||||
}
|
||||
} else if args.EndDate != "" {
|
||||
return time.Time{}, time.Time{}, fmt.Errorf("end_date 不能单独提供,请同时提供 start_date")
|
||||
}
|
||||
end := start
|
||||
if args.EndDate != "" {
|
||||
@@ -27,7 +35,6 @@ func forecastDates(args model.WeatherArguments, now time.Time) (time.Time, time.
|
||||
return time.Time{}, time.Time{}, fmt.Errorf("end_date 必须是 YYYY-MM-DD 格式的有效日期")
|
||||
}
|
||||
}
|
||||
today, _ := time.ParseInLocation(time.DateOnly, now.In(zone).Format(time.DateOnly), zone)
|
||||
last := today.AddDate(0, 0, 15)
|
||||
if end.Before(start) {
|
||||
return time.Time{}, time.Time{}, fmt.Errorf("结束日期不能早于开始日期")
|
||||
|
||||
Reference in new issue
Block a user