Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Timeline Doesn't Work With Dates Before Common Era #307

Closed
sarcanon opened this issue Sep 12, 2014 · 23 comments
Closed

Timeline Doesn't Work With Dates Before Common Era #307

sarcanon opened this issue Sep 12, 2014 · 23 comments

Comments

@sarcanon
Copy link

When I attempt to display a Timeline data set containing dates before the Common Era (i.e., B.C.), the results are incorrect and inconsistent, either not being displayed at all, or are displayed as though they were A.D. For example, a data set item with a start date of "-700-01-01" and end date of "-500-12-31" will either not appear, or after some zooming of and moving about of the timeline, may appear, but is rendered as though the dates were 700 and 500 A.D., not B.C.

Does Timeline not support pre-Common Era dates?

Apart from this one issue, this library suits all my needs quite nicely.

@josdejong
Copy link
Contributor

Thanks, I see indeed negative years in a string date are interpreted as positive. Using javascript Dates works fine though (i.e. new Date(-700, 0, 1) (mind the zero-based month) instead of "-700-01-01").

The date parsing is done by moment.js. I asked on stackoverflow about this behavior:
http://stackoverflow.com/questions/25846123/how-to-format-bc-dates-like-700-01-01-with-moment-js

@sarcanon
Copy link
Author

Excellent, thank you. However, if I do as you suggest, vis.js gives me an error, saying it failed to load the object. So I must be serializing incorrectly. To make things simple, I've reduced my json data to a single event:

[
{"content": "2nd Millenium BCE", "start": new Date(-2000, 0, 1), "end": new Date(-1000, 11, 31), "id": 4}
]

Can you please tell me what I am doing wrong?

Thank you.

@josdejong
Copy link
Contributor

new Date(-2000, 0, 1) is a JavaScript object which is not serializable. You will need to serialize to a string or number.

Using timestamps:

[
  {
    "content": "2nd Millenium BCE", 
    "start": -125281126800000, 
    "end": -93692682000000, 
    "id": 4
  }
]

or use this six number year notation I mention in the stackoverflow issue, but I don't know why this works and if that's intended:

[
  {
    "content": "2nd Millenium BCE", 
    "start": "-002000-01-01", 
    "end": "-001000-11-31", 
    "id": 4
  }
]

@AlexDM0
Copy link
Contributor

AlexDM0 commented Oct 23, 2014

Is this still an issue?

@mohsincynexis
Copy link

Hello Guys,

Can I go back 13.7 billion years ago?
How would I handle this date in the timeline.

@josdejong
Copy link
Contributor

Can I go back 13.7 billion years ago?

Just try it. I think it should work as long as you don't use ISODates but unix timestamps or Dates

@mohsincynexis
Copy link

how would i get the unix timestamp for 13.7 billion years?

@josdejong
Copy link
Contributor

sorry I mean a timestamp in milliseconds.

Just google for how timestamps and Dates work.

@mohsincynexis
Copy link

But its a very long number and vis is not going back after 2 lac 70 k

@imCaps
Copy link

imCaps commented Mar 16, 2016

Use negative integer. But do not forget about 32 and 64bit systems.
http://unix.stackexchange.com/questions/25361/why-does-unix-store-timestamps-in-a-signed-integer

@mohsincynexis
Copy link

Can you simply let me know how would I use 13.7 billion BC in this format
[
{"id": 1, "content": "item 1
start", "start": "2014-01-23"},
]

I know for BC i have to use negative years of max 6 length .
My system is 64 bit windows 7.

Now can any one of you simply let me know the figure to use in start value for plotting 13.7 billion years ago point on the timeline.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Mar 16, 2016

Its impossible, can't go further than new Date(-8.64e15).

@imCaps
Copy link

imCaps commented Mar 16, 2016

One solution(in specific cases) is correct Timeline format. Instead of years or other time labels use custom time like 'Y billion'.

@mohsincynexis
Copy link

Can you explain more on this.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Mar 16, 2016

The label changing is very tricky. If you want an interactive timeline you will get the fractions of the years which will not make sense. I'd suggest @mohsincynexis should experiment a bit. This would be easier when we port the dataaxis of graph2d over to the time axis and have custom labels. Just hide the time axis and insert a datetime label to your items.

@imCaps
Copy link

imCaps commented Mar 16, 2016

This is just one 'backdoor'. Not in all cases it can be used. For example, your timeline consists only "big timestamps". Like 17.3 billion BC, 25 AC, 123AC ... And you do not use "small timestamps"(seconds, minutes). You can bind minutes like a years and years like billion years.

var options = {
    end: duration,
    start: 0,
    format: {
        majorLabels: {
            minutes: "mm years", // This is not correctly written
            years: "Y,m billion years" // And this
        }
    }
};

This is just idea sketch but I believe it is working solution.

@mohsincynexis
Copy link

We are using minutes but not seconds

@mohsincynexis
Copy link

It would be a great help for me if you would post the the complete working example here please.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Mar 16, 2016

You've been provided with all required information. These issues are not here to do your work for you. If you encounter problems, create a JSBin and show us the issue.

@mohsincynexis
Copy link

how would it affect the date after changing the labels or do I have to make some calculations.
Like if a user enters date 2 80 000 BC Feb 25 12:30 then how would this be handled.

@AlexDM0
Copy link
Contributor

AlexDM0 commented Mar 17, 2016

It would crash and there's nothing we can do about it. Or you could just try it and see for yourself.

@mohsincynexis
Copy link

Hi Imcaps,

I have set the new labels but its appearing strange in the timeline like this -270007, biJun 10, -270007ion y4amr6

here is the format I am using

format: {
        minorLabels: {
          millisecond:'SSS',
          second:     's',
          minute:     'HH:mm',
          hour:       'HH:mm',
          weekday:    'ddd D',
          day:        'D',
          month:      'MMM',
          year:       'YYYY'
        },
        majorLabels: {
          millisecond:'HH:mm:ss',
          second:     'D MMMM HH:mm',
          minute:     'ddd D MMMM',
          hour:       'ddd D MMMM',
          weekday:    'MMMM YYYY',
          day:        'MMMM YYYY',
          month:      'YYYY',
          year:       'Y, billion years'
        }
      }

@ssabba
Copy link

ssabba commented Dec 28, 2016

very good

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants