@@ -248,19 +248,25 @@ func (b *BaseDB) FixFaultyTimestamps(ctx context.Context) error {
248248 defer tx .Rollback () //nolint: errcheck
249249
250250 for _ , swap := range loopOutSwaps {
251- faultyTime , err := parseTimeStamp (swap .PublicationDeadline )
251+
252+ // Get the year of the timestamp.
253+ year , err := getTimeStampYear (swap .PublicationDeadline )
252254 if err != nil {
253255 return err
254256 }
255257
256- // Skip if the time is not faulty.
257- if ! isMilisecondsTime (faultyTime .Unix ()) {
258+ // Skip if the year is not in the future.
259+ thisYear := time .Now ().Year ()
260+ if year <= thisYear {
258261 continue
259262 }
260263
264+ fixedTime , err := fixTimeStamp (swap .PublicationDeadline )
265+ if err != nil {
266+ return err
267+ }
268+
261269 // Update the faulty time to a valid time.
262- secs := faultyTime .Unix () / 1000
263- correctTime := time .Unix (secs , 0 )
264270 _ , err = tx .ExecContext (
265271 ctx , `
266272 UPDATE
@@ -270,7 +276,7 @@ func (b *BaseDB) FixFaultyTimestamps(ctx context.Context) error {
270276 WHERE
271277 swap_hash = $2;
272278 ` ,
273- correctTime , swap .Hash ,
279+ fixedTime , swap .Hash ,
274280 )
275281 if err != nil {
276282 return err
@@ -309,7 +315,7 @@ func (r *SqliteTxOptions) ReadOnly() bool {
309315 return r .readOnly
310316}
311317
312- // parseTimeStamp tries to parse a timestamp string with both the
318+ // fixTimeStamp tries to parse a timestamp string with both the
313319// parseSqliteTimeStamp and parsePostgresTimeStamp functions.
314320// If both fail, it returns an error.
315321func fixTimeStamp (dateTimeStr string ) (time.Time , error ) {
0 commit comments