Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use dates before 1960? #83

Open
joshua-reynolds opened this issue Oct 25, 2016 · 1 comment
Open

Can't use dates before 1960? #83

joshua-reynolds opened this issue Oct 25, 2016 · 1 comment

Comments

@joshua-reynolds
Copy link

Hi,

I'm trying to use a gpx feature that has dates taking place in the 1800's in example #9. I'm guessing because the app uses UTC (which was formalized in 1960), dates before that cause the script to break. Is there anyway to get around this?

I'd really like to be able to display dates in the 1800's.

Greatly appreciate any help!

@apulverizer
Copy link
Contributor

Part of the problem is in timedimension.control.js line 303-322:

_update: function() {
        if (!this._timeDimension) {
            return;
        }
        var time = this._timeDimension.getCurrentTime();
        if (time > 0) {
            var date = new Date(time);
            if (this._displayDate) {
                L.DomUtil.removeClass(this._displayDate, 'loading');
                this._displayDate.innerHTML = this._getDisplayDateFormat(date);
            }
            if (this._sliderTime && !this._slidingTimeSlider) {
                this._sliderTime.setValue(this._timeDimension.getCurrentTimeIndex());
            }
        } else {
            if (this._displayDate) {
                this._displayDate.innerHTML = this._getDisplayNoTimeError();
            }
        }
    },

If dates are before 1/1/1970 the epoch/unix timestamp will be negative. Since the time is checked to see if it is greater than 0, this fails and the NoTimeError message is rendered.

I think this might be fixed by changing line 308 to be:

if (this._timedimension.getCurrentTimeIndex() >=0) {

Also in timedimension.js, the getCurrentTime function returns 0 if the index isn't valid, maybe this should return null instead?

 getCurrentTime: function () {
        var index = -1;
        if (this._loadingTimeIndex !== -1) {
            index = this._loadingTimeIndex;
        } else {
            index = this.getCurrentTimeIndex();
        }
        if (index >= 0) {
            return this._availableTimes[index];
        } else {
            return 0;
        }
    },

bielfrontera pushed a commit that referenced this issue Dec 3, 2021
* 1970-01-01T00:00:00.000Z is 0 in milliseconds.
A check for time = 0 in WMS TD Layer returned the base layer without the time param thus
the correct request is never made.

Related to : #83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants