From 3fcc1f3c55d4380ff708ffc2e40396a0c09ab8a1 Mon Sep 17 00:00:00 2001 From: Trevor Robinson Date: Sat, 10 Aug 2019 21:35:02 -0500 Subject: [PATCH] Remove default arguments to support node 4 --- lib/packets/packet.js | 10 ++++++---- test/integration/connection/test-datetime.js | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/packets/packet.js b/lib/packets/packet.js index 595b8707a0..9edd1b6b43 100644 --- a/lib/packets/packet.js +++ b/lib/packets/packet.js @@ -289,7 +289,7 @@ class Packet { return new Date(str + timezone); } - readDateTimeString(decimals, timeSep = ' ') { + readDateTimeString(decimals, timeSep) { const length = this.readInt8(); let y = 0; let m = 0; @@ -309,9 +309,11 @@ class Packet { H = this.readInt8(); M = this.readInt8(); S = this.readInt8(); - str += `${timeSep}${[leftPad(2, H), leftPad(2, M), leftPad(2, S)].join( - ':' - )}`; + str += `${timeSep || ' '}${[ + leftPad(2, H), + leftPad(2, M), + leftPad(2, S) + ].join(':')}`; } if (length > 10) { ms = this.readInt32(); diff --git a/test/integration/connection/test-datetime.js b/test/integration/connection/test-datetime.js index c089a25af0..8e50216e3f 100644 --- a/test/integration/connection/test-datetime.js +++ b/test/integration/connection/test-datetime.js @@ -29,12 +29,18 @@ const date3 = null; const date4 = '2010-12-10 14:12:09.123456'; const date5 = '2010-12-10 14:12:09.019'; -function adjustTZ(d, offset = d.getTimezoneOffset()) { +function adjustTZ(d, offset) { + if (offset === undefined) { + offset = d.getTimezoneOffset(); + } return new Date(d.getTime() - offset * 60000); } -function toMidnight(d, offset = d.getTimezoneOffset()) { +function toMidnight(d, offset) { const t = d.getTime(); + if (offset === undefined) { + offset = d.getTimezoneOffset(); + } return new Date(t - (t % (24 * 60 * 60 * 1000)) + offset * 60000); } @@ -42,8 +48,11 @@ function formatUTCDate(d) { return d.toISOString().substring(0, 10); } -function formatUTCDateTime(d, precision = 0) { +function formatUTCDateTime(d, precision) { const raw = d.toISOString().replace('T', ' '); + if (precision === undefined) { + precision = 0; + } return precision <= 3 ? raw.substring(0, 19 + (precision && 1) + precision) : raw.substring(0, 23) + '0'.repeat(precision - 3);