index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. export default (function (o, c) {
  2. // locale needed later
  3. var proto = c.prototype;
  4. proto.$g = function (input, get, set) {
  5. if (this.$utils().u(input)) return this[get];
  6. return this.$set(set, input);
  7. };
  8. proto.set = function (string, _int) {
  9. return this.$set(string, _int);
  10. };
  11. var oldStartOf = proto.startOf;
  12. proto.startOf = function (units, startOf) {
  13. this.$d = oldStartOf.bind(this)(units, startOf).toDate();
  14. this.init();
  15. return this;
  16. };
  17. var oldAdd = proto.add;
  18. proto.add = function (number, units) {
  19. this.$d = oldAdd.bind(this)(number, units).toDate();
  20. this.init();
  21. return this;
  22. };
  23. var oldLocale = proto.locale;
  24. proto.locale = function (preset, object) {
  25. if (!preset) return this.$L;
  26. this.$L = oldLocale.bind(this)(preset, object).$L;
  27. return this;
  28. };
  29. var oldDaysInMonth = proto.daysInMonth;
  30. proto.daysInMonth = function () {
  31. return oldDaysInMonth.bind(this.clone())();
  32. };
  33. var oldIsSame = proto.isSame;
  34. proto.isSame = function (that, units) {
  35. return oldIsSame.bind(this.clone())(that, units);
  36. };
  37. var oldIsBefore = proto.isBefore;
  38. proto.isBefore = function (that, units) {
  39. return oldIsBefore.bind(this.clone())(that, units);
  40. };
  41. var oldIsAfter = proto.isAfter;
  42. proto.isAfter = function (that, units) {
  43. return oldIsAfter.bind(this.clone())(that, units);
  44. };
  45. });