DayOfMonthExpression.js 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. /**
  3. * Get the DayOfMonth from a date.
  4. * @class DayOfMonthExpression
  5. * @namespace mungedb-aggregate.pipeline.expressions
  6. * @module mungedb-aggregate
  7. * @constructor
  8. **/
  9. var DayOfMonthExpression = module.exports = function DayOfMonthExpression() {
  10. base.call(this);
  11. }, klass = DayOfMonthExpression,
  12. FixedArityExpression = require("./FixedArityExpressionT")(klass, 1),
  13. base = FixedArityExpression,
  14. proto = klass.prototype = Object.create(base.prototype, {
  15. constructor: {
  16. value: klass
  17. }
  18. });
  19. // DEPENDENCIES
  20. var Expression = require("./Expression");
  21. // PROTOTYPE MEMBERS
  22. proto.getOpName = function getOpName() {
  23. return "$dayOfMonth";
  24. };
  25. /**
  26. * Takes a date and returns the day of the month as a number between 1 and 31.
  27. * @method evaluate
  28. **/
  29. proto.evaluateInternal = function evaluateInternal(vars) {
  30. var date = this.operands[0].evaluateInternal(vars);
  31. return date.getUTCDate();
  32. };
  33. /** Register Expression */
  34. Expression.registerExpression("$dayOfMonth", base.parse);