From 43834e9fecebfcd214f7b62f8c5caadaf050ea23 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sat, 21 Mar 2015 09:30:14 -0400 Subject: [PATCH] Add dogapi.now helper method --- lib/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/index.js b/lib/index.js index 893bb13..4d77121 100644 --- a/lib/index.js +++ b/lib/index.js @@ -31,8 +31,23 @@ function initialize(options){ } }; +/*section: dogapi + *comment: get the current POSIX timestamp + *example: | + * ```javascript + * var dogapi = require("dogapi"); + * dogapi.now(); + * // this is the same as + * parseInt(new Date().getTime() / 1000); + * ``` + */ +function now(){ + return parseInt(new Date().getTime() / 1000); +}; + module.exports.client = require("./client"), module.exports.initialize = initialize; +module.exports.now = now; module.exports.OK = 0; module.exports.WARNING = 1; module.exports.CRITICAL = 2;