SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
Fix date string parsing bug for the SQL Engine. (#7446)
Lisandro Pin5fef4145a4cd
diff --git a/weed/query/engine/function_helpers.go b/weed/query/engine/function_helpers.goindex 60eccdd37a..50f71dc084 100644--- a/weed/query/engine/function_helpers.go+++ b/weed/query/engine/function_helpers.go@@ -102,22 +102,18 @@ func (e *SQLEngine) valueToTime(value *schema_pb.Value) (time.Time, error) {case *schema_pb.Value_StringValue:// Try to parse various date/time string formatsdateFormats := []struct {- format string- useLocal bool+ format string+ tz *time.Location}{- {"2006-01-02 15:04:05", true}, // Local time assumed for non-timezone formats- {"2006-01-02T15:04:05Z", false}, // UTC format- {"2006-01-02T15:04:05", true}, // Local time assumed- {"2006-01-02", true}, // Local time assumed for date only- {"15:04:05", true}, // Local time assumed for time only+ {"2006-01-02 15:04:05", time.Local}, // Local time assumed for non-timezone formats+ {"2006-01-02T15:04:05Z", time.UTC}, // UTC format+ {"2006-01-02T15:04:05", time.Local}, // Local time assumed+ {"2006-01-02", time.Local}, // Local time assumed for date only+ {"15:04:05", time.Local}, // Local time assumed for time only}for _, formatSpec := range dateFormats {- if t, err := time.Parse(formatSpec.format, v.StringValue); err == nil {- if formatSpec.useLocal {- // Convert to UTC for consistency if no timezone was specified- return time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.UTC), nil- }+ if t, err := time.ParseInLocation(formatSpec.format, v.StringValue, formatSpec.tz); err == nil {return t, nil}}