DSP.jl Side Effect on Dates

Interestingly I found with Julia Version 1.7.2 (2022-02-06) for window the following side effect:

No Bug
using Dates
datenow=Dates.format(Dates.now(),“yyyymmddTHHMMSSZ”)

Buggy
using DSP
using Dates
datenow=Dates.format(Dates.now(),“yyyymmddTHHMMSSZ”)

Returns:
ERROR: type DateTime has no field zone

Note that the same effect is obtained by loading just one of the DSP module
#using DSP
include(“remez_fir.jl”)
using Dates
datenow=Dates.format(Dates.now(),“yyyymmddTHHMMSSZ”)

Interesting but not too interesting…

1 Like

Examining the Dates.jl and DSP.jl code I found the reason for this error.
It’s because one of the DSP.jl indirect dependencies is TimeZones.jl. TimeZones.jl uses the strings “Z” and “z” to create objects of type ZonedDateTime:
https://juliatime.github.io/TimeZones.jl/stable/conversions/#Parsing-strings-1

2 Likes

I would recommend that you always escape letters that you don’t want to be substituted as part of the formatting with \. For example:

fmt = dateformat"yyyymmdd\THHMMSS\Z"
Dates.format(Dates.now(), fmt)

where, regardless if some package adds a meaning for T and Z, you will get the expected output.

2 Likes