* MailPacket class: read() and write() with event emits

* FTNMailPacket WIP derived from MailPacket
This commit is contained in:
Bryan Ashby 2015-07-15 23:51:00 -06:00
parent 7fa27e46a5
commit aebf494ae7
5 changed files with 189 additions and 15 deletions

View file

@ -12,10 +12,11 @@ var util = require('util');
exports.stringFromFTN = stringFromFTN;
exports.getFormattedFTNAddress = getFormattedFTNAddress;
exports.getDateFromFtnDateTime = getDateFromFtnDateTime;
// See list here: https://github.com/Mithgol/node-fidonet-jam
// :TODO: proably move this elsewhere as a general method
function stringFromFTN(buf, encoding) {
var nullPos = buf.length;
for(var i = 0; i < buf.length; ++i) {
@ -28,6 +29,20 @@ function stringFromFTN(buf, encoding) {
return buf.slice(0, nullPos).toString(encoding || 'utf-8');
}
//
// Convert a FTN style DateTime string to a Date object
//
function getDateFromFtnDateTime(dateTime) {
//
// Examples seen in the wild (Working):
// "12 Sep 88 18:17:59"
// "Tue 01 Jan 80 00:00"
// "27 Feb 15 00:00:03"
//
return (new Date(Date.parse(dateTime))).toISOString();
}
function getFormattedFTNAddress3D(zone, net, node) {
return util.format('%d:%d/%d', zone, net, node);
}