zkteco-js
Version:
The zkteco library allows Node.js developers to easily interface with ZK BioMetric Fingerprint Attendance Devices, extract and manage data, and integrate biometric features into attendance systems efficiently.
42 lines (34 loc) • 848 B
JavaScript
/**
*
* Author: coding-libs
* Date: 2024-07-01
*/
/**
*
* @param {number} time
*/
exports.decode = time => {
const second = time % 60;
time = (time - second) / 60;
const minute = time % 60;
time = (time - minute) / 60;
const hour = time % 24;
time = (time - hour) / 24;
const day = time % 31 + 1;
time = (time - (day - 1)) / 31;
const month = time % 12;
time = (time - month) / 12;
const year = time + 2000;
return new Date(year, month, day, hour, minute, second);
};
/**
*
* @param {Date} date
*/
exports.encode = date => {
return (
((date.getFullYear() % 100) * 12 * 31 + date.getMonth() * 31 + date.getDate() - 1) * (24 * 60 * 60) +
(date.getHours() * 60 + date.getMinutes()) * 60 +
date.getSeconds()
);
};