-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Please forgive me in advance for this rush job as I literally only spent less than 30 minutes on this, but it seems that the current driver drops milliseconds from timestamps coming out of the database. I hacked a test together based off the encode tests (I don't think that there is an easy way for me to get a DB type constant since they are private, so I hardcoded the 1184).
I have a pending, (equally rushed) PR, but just wanted to bring this up in case I'm overlooking some reason why things are (or have to be) the way they are.
solo_test('decode datetime', () {
var data = [
"22001-02-03 00:00:00.000", new DateTime(22001, DateTime.FEBRUARY, 3),
"2001-02-03 00:00:00.000", new DateTime(2001, DateTime.FEBRUARY, 3),
"2001-02-03 04:05:06.000", new DateTime(2001, DateTime.FEBRUARY, 3, 4, 5, 6, 0),
// FAILS!
"2001-02-03 04:05:06.999", new DateTime(2001, DateTime.FEBRUARY, 3, 4, 5, 6, 999),
"0010-02-03 04:05:06.123 BC", new DateTime(-10, DateTime.FEBRUARY, 3, 4, 5, 6, 123),
"0010-02-03 04:05:06.000 BC", new DateTime(-10, DateTime.FEBRUARY, 3, 4, 5, 6, 0)
//TODO test minimum allowable postgresql date
];
var tc = new TypeConverter();
var d = new DateTime.now().timeZoneOffset; // Get users current timezone
pad(int i) => i.toString().padLeft(2, '0');
var tzoff = '${d.isNegative ? '-' : '+'}'
'${d.inHours}:${pad(d.inMinutes % 60)}:${pad(d.inSeconds % 60)}';
for (int i = 0; i < data.length; i += 2) {
var str = data[i];
var dt = data[i + 1];
expect(tc.decode(str, 1184), dt);
}
});
Metadata
Metadata
Assignees
Labels
No labels