socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
433 stars 138 forks source link

Mixing times from before and after 2001 breaks #228

Open hansthen opened 4 months ago

hansthen commented 4 months ago

When providing a GeoJson that has dates from before and after 2001-09-09 the Timedimension breaks.

This issue was originally discovered and reported when using the Folium package: see https://github.com/python-visualization/folium/issues/1268 for more background.

The issue may be related to the fact that during 2001-09-09 an extra digit was added in the unix timestamp.

User @davecao suggests the following fix:

In the function sort_and_deduplicate change the line arr = arr.slice(0).sort() to arr = arr.slice(0).sort(function(a, b){return a-b;});

hansthen commented 4 months ago

The issue seems to be resolved in source code, but not yet published to the CDN. See https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/src/leaflet.timedimension.util.js, which does not have the suggested changes. Would it be possible to release the latest version of the code to CDN?

See git blame, which was made a few days after the 1.1.1 release.

de8e568c (Amir Livne Bar-on 2017-12-02 14:00:16 +0200 200)     sort_and_deduplicate: function(arr) {
8403a32a (Biel Frontera     2019-11-19 16:44:53 +0100 201)         arr = arr.slice(0).sort(function (a, b) {
8403a32a (Biel Frontera     2019-11-19 16:44:53 +0100 202)             return a - b;
8403a32a (Biel Frontera     2019-11-19 16:44:53 +0100 203)         });