| 123456789101112131415161718192021222324252627 |
- var SecondExpression = module.exports = (function(){
- // CONSTRUCTOR
- /** A $second pipeline expression. @see evaluate **/
- var klass = function SecondExpression(){
- if(arguments.length !== 0) throw new Error("zero args expected");
- base.call(this);
- }, base = require("./NaryExpression"), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
- // PROTOTYPE MEMBERS
- proto.getOpName = function getOpName(){
- return "$second";
- };
- proto.addOperand = function addOperand(expr) {
- this.checkArgLimit(1);
- base.addOperand(expr);
- };
- /** Takes a date and returns the second between 0 and 59, but can be 60 to account for leap seconds. **/
- proto.evaluate = function evaluate(doc){
- this.checkArgCount(1);
- var date = this.operands[0].evaluate(doc);
- return date.getSeconds(); //TODO: incorrect for last second of leap year, need to fix...
- };
- return klass;
- })();
|