Browse Source

Added year/y to date math parser

Rashid Khan 12 years ago
parent
commit
4e6bc71f49
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/app/components/kbn.js

+ 9 - 0
src/app/components/kbn.js

@@ -316,6 +316,15 @@ function($, _, moment) {
       }
       }
       unit = mathString.charAt(i++);
       unit = mathString.charAt(i++);
       switch (unit) {
       switch (unit) {
+      case 'y':
+        if (type === 0) {
+          roundUp ? dateTime.endOf('year') : dateTime.startOf('year');
+        } else if (type === 1) {
+          dateTime.add('years',num);
+        } else if (type === 2) {
+          dateTime.subtract('years',num);
+        }
+        break;
       case 'M':
       case 'M':
         if (type === 0) {
         if (type === 0) {
           roundUp ? dateTime.endOf('month') : dateTime.startOf('month');
           roundUp ? dateTime.endOf('month') : dateTime.startOf('month');