0

Currently attempting to parse a managable datetime from a binary 'file'. Since the file is being uploaded in a web app, I am using javascript.

var reader = new FileReader();
reader.readAsArrayBuffer( file );
var arrayBuffer = reader.result;
var slice = arrayBuffer.slice( 1, 9 );
var date = new Uint32Array( slice );
console.log(date);

Console reports 'date' as

Uint32Array(2) [3068092018, 30617747]
0:3068092018
1:30617747
buffer:(...)
byteLength:(...)
byteOffset:(...)
length:(...)
Symbol(Symbol.toStringTag):(...)
__proto__:TypedArray

or

date[0] = 3068092018
date[1] = 30617747

Unfortunately I have very little experience manipulating binary / big ints, in fact I don't even understand what format this is being stored in. How do I convert this into a manageable DateTime stamp for insertion into SQLite3?

Hikalea
  • 119
  • 2
  • 10

1 Answers1

0

var dateString = moment.unix(30617747).format("MM/DD/YYYY");

console.log(dateString) 
<script src="https://momentjs.com/downloads/moment.js"></script>
Deano
  • 11,582
  • 18
  • 69
  • 119
  • Maybe in chrome try Right-click an object in Chrome's console and select Store as Global Variable from the context menu. It will return something like temp1 as the variable name. Chrome also has a copy() method, so copy(temp1) in the console should copy that object to your clipboard, update your question with object :) – Deano Sep 21 '17 at 03:19
  • Returns 'undefined.' I am reading binary and storing in an arraybuffer, then after parsing a 'slice' of that arraybuffer I am storing that value in a Uint32Array. – Hikalea Sep 21 '17 at 03:27
  • Well, I'm not sure if slice is manipulating the integrity of date value :-/ I was hoping to see the full js object to try and understand date format – Deano Sep 21 '17 at 03:36