@@ -90,19 +90,68 @@ func Test_parseExifTime(t *testing.T) {
90
90
wantErr bool
91
91
}{
92
92
{
93
- name : "valid date with different separators in local timezone" ,
93
+ name : "valid date with different separators in local timezone" ,
94
94
date : "2023-10-06 08:30:00" ,
95
95
location : time .Local ,
96
96
want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , 0 , time .Local ),
97
97
wantErr : false ,
98
98
},
99
99
{
100
- name : "valid date with milliseconds in local timezone" ,
100
+ name : "valid date with milliseconds in local timezone" ,
101
101
date : "2023-10-06 08:30:00.123" ,
102
102
location : time .Local ,
103
103
want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , int (123 * time .Millisecond ), time .Local ),
104
104
wantErr : false ,
105
105
},
106
+ {
107
+ name : "valid date with different separators in UTC timezone" ,
108
+ date : "2023-10-06 08:30:00" ,
109
+ location : time .UTC ,
110
+ want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , 0 , time .UTC ),
111
+ wantErr : false ,
112
+ },
113
+ {
114
+ name : "valid date with milliseconds in UTC timezone" ,
115
+ date : "2023/10/06 08:30:00.123" ,
116
+ location : time .UTC ,
117
+ want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , int (123 * time .Millisecond ), time .UTC ),
118
+ wantErr : false ,
119
+ },
120
+ {
121
+ name : "date format with different separators" ,
122
+ date : "2023/10/06 08:30:00" ,
123
+ location : time .Local ,
124
+ want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , 0 , time .Local ),
125
+ wantErr : false ,
126
+ },
127
+ {
128
+ name : "date format with milliseconds" ,
129
+ date : "2023/10/06 08:30:00.123" ,
130
+ location : time .Local ,
131
+ want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , int (123 * time .Millisecond ), time .Local ),
132
+ wantErr : false ,
133
+ },
134
+ {
135
+ name : "empty date string" ,
136
+ date : "" ,
137
+ location : time .Local ,
138
+ want : time.Time {},
139
+ wantErr : true ,
140
+ },
141
+ {
142
+ name : "date string with extra spaces" ,
143
+ date : " 2023-10-06 08:30:00 " ,
144
+ location : time .Local ,
145
+ want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , 0 , time .Local ),
146
+ wantErr : false ,
147
+ },
148
+ {
149
+ name : "date string with extra spaces and milliseconds" ,
150
+ date : " 2023-10-06 08:30:00.123 " ,
151
+ location : time .Local ,
152
+ want : time .Date (2023 , 10 , 6 , 8 , 30 , 0 , int (123 * time .Millisecond ), time .Local ),
153
+ wantErr : false ,
154
+ },
106
155
}
107
156
for _ , tt := range tests {
108
157
t .Run (tt .name , func (t * testing.T ) {
0 commit comments