hackernews2nntp
Version:
Post Hacker News Stories & Comments to an NNTP Server
22 lines (17 loc) • 768 B
JavaScript
// Generated by CoffeeScript 1.8.0
(function() {
var pad;
pad = function(str) {
return ('0' + str).slice(-2);
};
exports.prefix = function(json_data) {
var d, days, months;
d = new Date(json_data.time * 1000);
days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
return ["From " + json_data.by + "@example.com", days[d.getUTCDay()], months[d.getUTCMonth()], pad(d.getUTCDate()), [pad(d.getUTCHours()), pad(d.getUTCMinutes()), pad(d.getUTCSeconds())].join(':'), d.getUTCFullYear()].join(' ');
};
exports.escape = function(mail) {
return mail != null ? mail.replace(/\n((>*?)From .+)/g, '\n>$1') : void 0;
};
}).call(this);