getFieldStringDateTime method
Implementation
String? getFieldStringDateTime(DateTime? d) {
// Sanity check
if (d == null) return null;
final int difference =
d.millisecondsSinceEpoch - DbaseFileHeader.MILLIS_SINCE_4713;
final int days = (difference ~/ MILLISECS_PER_DAY);
final int time = (difference % MILLISECS_PER_DAY);
List<int> outBytes = [
...ByteConversionUtilities.bytesFromInt32(days),
...ByteConversionUtilities.bytesFromInt32(time),
];
return String.fromCharCodes(outBytes);
// try (ByteArrayOutputStream o_bytes = new ByteArrayOutputStream();
// DataOutputStream o_stream =
// new DataOutputStream(new BufferedOutputStream(o_bytes))) {
// B
// o_stream.writeInt(days);
// o_stream.writeInt(time);
// o_stream.flush();
// byte[] bytes = o_bytes.toByteArray();
// // Cast the byte values to char as a workaround for erroneous byte
// // array retrieval in 64-bit machines
// char[] out = {
// // Days, after reverse.
// (char) bytes[3], (char) bytes[2], (char) bytes[1], (char) bytes[0],
// // Time in millis, after reverse.
// (char) bytes[7], (char) bytes[6], (char) bytes[5], (char) bytes[4],
// };
// return new String(out);
// } catch ( e) {
// // This is always just a int serialization,
// // there is no way to recover from here.
// return null;
// }
}