Getting year 2106 from NTPClient.getEpochTime when NTP server unreachable

In my code I’m trying to update a DS3231 RTC ONLY if it needs updating. NTP returns a date that’s way in the future, and the RTC is updated to a date/time in year 2106. If the NTP server is reachable, then all is OK. This only happens when WiFi is down of NTP otherwise unreachable.
So, I asked Copilot about the issue and it was suggested to downgrade the library to 2.7.4 (now at arduino-libraries/NTPClient@^3.2.1). I edited my project’s platformio.ini thusly:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
arduino-libraries/NTPClient@^2.7.4

And I get the following after the edit in the output window:
Resolving d1_mini dependencies…
Removing unused dependencies…
SemanticVersionError: Invalid simple block ‘^’

This has me baffled - I have to comment out all library dependencies to get rid of the message. It builds OK but why I don’t know because the lib_deps are commented out now. Any ideas for that message? I’m at a loss here.

The error SemanticVersionError: Invalid simple block ‘^’ is related to the way you are specifying the version number for the NTPClient library in your platformio.ini file.
In PlatformIO, the lib_deps option uses the semantic versioning syntax for specifying library versions. The ^ symbol is used to specify a “compatible” version range, but it seems that PlatformIO is having trouble parsing this syntax for the specific version you’re trying to specify (arduino-libraries/NTPClient@^2.7.4).
Instead of using the ^ symbol, you can try specifying the exact version number without any special characters:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps = arduino-libraries/NTPClient@2.7.4

This should install the specific version 2.7.4 of the NTPClient library without any issues.

If you still encounter problems, you can try a different approach to specify the library version:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
    https://github.com/arduino-libraries/NTPClient.git#v2.7.4
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
    https://github.com/arduino-libraries/NTPClient.git#v2.7.4

This way, you’re directly specifying the Git repository URL and the specific tag or commit hash (v2.7.4) that you want to use.

If neither of these approaches work, you can try rebuilding the PlatformIO project cache by running the following command in your terminal:

pio pkg cache --force-refresh

This will clear the local cache and force PlatformIO to re-download all library dependencies, which might resolve any caching issues that could be causing the parsing error.

If you’re still having trouble after trying these suggestions, you may want to consider opening an issue on the PlatformIO GitHub repository or seeking further assistance from their support channels.