parso icon indicating copy to clipboard operation
parso copied to clipboard

Different timestamp formats parsing issue

Open nhrG opened this issue 4 years ago • 1 comments

Hi, I am trying to parse a sas file with timestamps, but I am unable to get correct time part of the timestamp. I was checking the source code, and for every timestamp format, column schema object return DATETIME_FORMAT_STRINGS.DATETIME. I also have a date with that format, but even that dates time part is parsed incorrectly. Attached are the used csv and created sas7bdat file via sas studio. Issue My Date - 13 May 1995 08:30:12 Date object from readNext() - Sat May 13 14:00:12 IST 1995 Parsed object as per format - 13May1995:14:00:12.00

How to recreate this bug?

  • Parso v2.0.13
  • Use timeSimple.sas7bdat
  • Simple reader, no encoding
  • Date formatter code new SimpleDateFormat(format).format((Date) object)

The timestamp is created correctly from imported csv, see screenshot issueTimestamps

Files timeSimple.zip

Version. Parso - 2.0.13 Java - v8

nhrG avatar Jun 10 '21 06:06 nhrG

Checked a bit more, I am guessing SasFileParser#bytesToDateTime() method is returning new Date as Local date, and interpreting the read GMT date to my local(IST) date - and adding 5:30hrs to the time. For instance -

byte[] bytes = [0, 0, 0, -3, -104, 5, -39, 65];

double doubleSeconds = 1.67918898E9;

Date date = new Date((long) ((doubleSeconds - START_DATES_SECONDS_DIFFERENCE)
                * MILLISECONDS_IN_SECONDS));
                * 
date; // Mon Mar 18 06:53:00 IST 2013

// Actual date is 18/03/13 01:23

Thoughts?

nhrG avatar Jun 11 '21 06:06 nhrG