1

I'm having difficulty parsing a string into data format using JavaScript. The issue is that there are no leading zeros. For example, in my JSON:

1/1/1993 is listed as: 33970

I've tried:

function dateMatch(data, value) {
  var formatTime = d3.timeFormat("%B %d, %Y");
  var d = formatTime(new Date(data.properties.Sign_Date.toString()));
  console.log(d)
}

No luck! What can I try next?

halfer
  • 19,824
  • 17
  • 99
  • 186
DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81
  • How is that a date? `33970` doesn't map to `1/1/1993` in any obvious way no matter how many leading zeroes you give it. – Herohtar Sep 28 '18 at 20:40
  • I have no idea.. it was converted from a csv to a geojson file.. and converted automatically. Hm. – DiamondJoe12 Sep 28 '18 at 20:45
  • 1
    @DiamondJoe12 This might be an issue when the csv is getting parsed into GeoJson. Do you have control over that process? – Tanner Eustice Sep 28 '18 at 20:56
  • 1
    @Herohtar 33,970 is a date in the sense that it is the number of days from 1/1/1900 to 1/1/1993; having said that, I've no idea what part of the overall process is arriving at this conversion, but knowing this might provide a hint or clue of where to look – landru27 Sep 28 '18 at 21:17
  • @landru27 Hmm, maybe, but both Google and WolframAlpha tell me that the number of days between those dates is 33,968. Exactly 33,970 days before 1/1/1993 is actually 12/30/1899. – Herohtar Sep 28 '18 at 21:33
  • I agree with @TannerEustice, this seems like something you need to look at in whatever is parsing the CSV into GeoJson. – Herohtar Sep 28 '18 at 21:41
  • 2
    @Herohtar : I stand corrected; your precision provides a clue: the internal epoch date for Microsoft Excel is evidently 12/30/1899; DiamondJoe12 : is perhaps "1/1/1993" shown on the spreadsheet, but your CSV already has "33970", i.e., in the export from the spreadsheet to the CSV file you are working with? at any rate, I fully agree with the gist of all these comments : there are several places to look in your overall conversion pipeline / process. – landru27 Sep 28 '18 at 21:59
  • 2
    citation for my previous comment : https://en.wikipedia.org/wiki/Epoch_(reference_date) : note, "Technical internal value used by Microsoft Excel; for compatibility with Lotus 1-2-3." – landru27 Sep 28 '18 at 22:00
  • 1
    Possible duplicate of [Converting Excel Date Serial Number to Date using Javascript](https://stackoverflow.com/questions/16229494/converting-excel-date-serial-number-to-date-using-javascript) – Alexandre Borela Sep 30 '18 at 15:14

0 Answers0