PageSourceSearch

https://nptemplating-docs.netlify.app/assets/js/e108a1fe.179546a7.js

js nptemplating-docs.netlify.app collected 2026-10-03 11:13:45 UTC 51,840 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunknp_templating=self.webpackChunknp_templating||[]).push([[3685],{3905:function(e,t,a){a.d(t,{Zo:function(){return d},kt:function(){return k}});var n=a(7294);function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function l(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function i(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?l(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):l(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function o(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},l=Object.keys(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}var p=n.createContext({}),s=function(e){var t=n.useContext(p),a=t;return e&&(a="function"==typeof e?e(t):i(i({},t),e)),a},d=function(e){var t=s(e.components);return n.createElement(p.Provider,{value:t},e.children)},m={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},u=n.forwardRef((function(e,t){var a=e.components,r=e.mdxType,l=e.originalType,p=e.parentName,d=o(e,["components","mdxType","originalType","parentName"]),u=s(a),k=r,N=u["".concat(p,".").concat(k)]||u[k]||m[k]||l;return a?n.createElement(N,i(i({ref:t},d),{},{components:a})):n.createElement(N,i({ref:t},d))}));function k(e,t){var a=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var l=a.length,i=new Array(l);i[0]=u;var o={};for(var p in t)hasOwnProperty.call(t,p)&&(o[p]=t[p]);o.originalType=e,o.mdxType="string"==typeof e?e:r,i[1]=o;for(var s=2;s<l;s++)i[s]=a[s];return n.createElement.apply(null,i)}return n.createElement.apply(null,a)}u.displayName="MDXCreateElement"},1347:function(e,t,a){a.r(t),a.d(t,{frontMatter:function(){return o},contentTitle:function(){return p},metadata:function(){return s},toc:function(){return d},default:function(){return u}});var n=a(7462),r=a(3366),l=(a(7294),a(3905)),i=["components"],o={sidebar_position:2},p="Date Module",s={unversionedId:"templating-modules/date-module",id:"templating-modules/date-module",title:"Date Module",description:"Overview",source:"@site/docs/templating-modules/date-module.md",sourceDirName:"templating-modules",slug:"/templating-modules/date-module",permalink:"/docs/templating-modules/date-module",editUrl:"https://github.com/mikeerickson/nptemplating-docs/tree/master/docs/templating-modules/date-module.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2},sidebar:"tutorialSidebar",previous:{title:"Modules Overview",permalink:"/docs/templating-modules/overview"},next:{title:"Time Module",permalink:"/docs/templating-modules/time-module"}},d=[{value:"Overview",id:"overview",children:[],level:2},{value:"Methods",id:"methods",children:[{value:"createDateTime",id:"createdatetime",children:[],level:3},{value:"now",id:"now",children:[],level:3},{value:"timestamp",id:"timestamp",children:[],level:3},{value:"date8601",id:"date8601",children:[],level:3},{value:"today",id:"today",children:[],level:3},{value:"tomorrow",id:"tomorrow",children:[],level:3},{value:"yesterday",id:"yesterday",children:[],level:3},{value:"format",id:"format",children:[],level:3},{value:"weekday",id:"weekday",children:[],level:3},{value:"weekNumber",id:"weeknumber",children:[],level:3},{value:"dayNumber",id:"daynumber",children:[],level:3},{value:"isWeekday",id:"isweekday",children:[],level:3},{value:"isWeekend",id:"isweekend",children:[],level:3},{value:"weekOf",id:"weekof",children:[],level:3},{value:"startOfWeek",id:"startofweek",children:[],level:3},{value:"endOfWeek",id:"endofweek",children:[],level:3},{value:"startOfMonth",id:"startofmonth",children:[],level:3},{value:"daysInMonth",id:"daysinmonth",children:[],level:3},{value:"endOfMonth",id:"endofmonth",children:[],level:3},{value:"daysBetween",id:"daysbetween",children:[],level:3},{value:"add",id:"add",children:[],level:3},{value:"businessAdd",id:"businessadd",children:[],level:3},{value:"subtract",id:"subtract",children:[],level:3},{value:"businessSubtract",id:"businesssubtract",children:[],level:3},{value:"nextBusinessDay",id:"nextbusinessday",children:[],level:3},{value:"previousBusinessDay",id:"previousbusinessday",children:[],level:3}],level:2},{value:"Using DateModule in NotePlan Plugins",id:"using-datemodule-in-noteplan-plugins",children:[{value:"Date Module Methods",id:"date-module-methods",children:[{value:"previousBusinessDay",id:"previousbusinessday-1",children:[],level:4},{value:"isWeekend",id:"isweekend-1",children:[],level:4}],level:3}],level:2},{value:"Helpers",id:"helpers",children:[{value:"now",id:"now-1",children:[],level:3},{value:"format",id:"format-1",children:[],level:3}
1,{value:"date8601",id:"date8601-1",children:[],level:3},{value:"timestamp",id:"timestamp-1",children:[],level:3}],level:2}],m={toc:d};function u(e){var t=e.components,o=(0,r.Z)(e,i);return(0,l.kt)("wrapper",(0,n.Z)({},m,o,{components:t,mdxType:"MDXLayout"}),(0,l.kt)("h1",{id:"date-module"},"Date Module"),(0,l.kt)("h2",{id:"overview"},"Overview"),(0,l.kt)("p",null,"The Date Module provides methods and variables which work with dates."),(0,l.kt)("div",{className:"admonition admonition-info alert alert--info"},(0,l.kt)("div",{parentName:"div",className:"admonition-heading"},(0,l.kt)("h5",{parentName:"div"},(0,l.kt)("span",{parentName:"h5",className:"admonition-icon"},(0,l.kt)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},(0,l.kt)("path",{parentName:"svg",fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),"info")),(0,l.kt)("div",{parentName:"div",className:"admonition-content"},(0,l.kt)("p",{parentName:"div"},"Refer to ",(0,l.kt)("a",{parentName:"p",href:"/docs/templating-modules/time-module"},"Time Module")," for similar methods which work with with time values)"))),(0,l.kt)("div",{className:"admonition admonition-info alert alert--info"},(0,l.kt)("div",{parentName:"div",className:"admonition-heading"},(0,l.kt)("h5",{parentName:"div"},(0,l.kt)("span",{parentName:"h5",className:"admonition-icon"},(0,l.kt)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},(0,l.kt)("path",{parentName:"svg",fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"}))),"info")),(0,l.kt)("div",{parentName:"div",className:"admonition-content"},(0,l.kt)("h4",{parentName:"div",id:"date-module-helpers"},"Date Module Helpers"),(0,l.kt)("p",{parentName:"div"},"The Date Module exposes commonly used ",(0,l.kt)("a",{parentName:"p",href:"/docs/templating-modules/date-module#helpers"},"helper")," methods"))),(0,l.kt)("div",{className:"admonition admonition-tip alert alert--success"},(0,l.kt)("div",{parentName:"div",className:"admonition-heading"},(0,l.kt)("h5",{parentName:"div"},(0,l.kt)("span",{parentName:"h5",className:"admonition-icon"},(0,l.kt)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"},(0,l.kt)("path",{parentName:"svg",fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"}))),"tip")),(0,l.kt)("div",{parentName:"div",className:"admonition-content"},(0,l.kt)("h4",{parentName:"div",id:"formatting-date-values"},"Formatting Date Values"),(0,l.kt)("p",{parentName:"div"},"The Date Module uses JavaScript ",(0,l.kt)("inlineCode",{parentName:"p"},"moment")," library internally, thus you can use any of the ",(0,l.kt)("a",{parentName:"p",href:"https://momentjs.com/docs/#/parsing/string-format/"},"moment formatting")," options."),(0,l.kt)("p",{parentName:"div"},(0,l.kt)("img",{alt:"NotePlan Event",src:a(9079).Z})),(0,l.kt)("p",{parentName:"div"},(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",{parentName:"div"},"If you wish to display date value with 4 digit year and 2 digit month, separated by a dash ",(0,l.kt)("inlineCode",{parentName:"p"},"-")," character, you would use ",(0,l.kt)("inlineCode",{parentName:"p"},"<%- date.now('YYYY-MM') %>")))),(0,l.kt)("h2",{id:"methods"},"Methods"),(0,l.kt)("blockquote",null,(0,l.kt)("p",{parentName:"blockquote"},"namespace: ",(0,l.kt)("inlineCode",{parentName:"p"},"date"))),(0,l.kt)("p",null,"The following are the methods available in the Date Module, and they can be used in any ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," template, no additional configuration required."),(0,l.kt)("div",{className:"admonition admonition-note alert alert--secondary"},(0,l.kt)("div",{parentName:"div",className:"admonition-heading"},(0,l.kt)("h5",{parentName:"div"},(0,l.kt)("span",{parentName:"h5",className:"admonition-icon"}
1,(0,l.kt)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},(0,l.kt)("path",{parentName:"svg",fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"}))),"note")),(0,l.kt)("div",{parentName:"div",className:"admonition-content"},(0,l.kt)("p",{parentName:"div"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," - Many of the Date Module methods accept a ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," argument, which means the date which will be used to perform the appropriate calculation.  When no ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," is supplied, the current date will be used."))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"createdatetime"},"createDateTime"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"createdatetimepivotdate--string-----date"},"createDateTime(pivotDate? : string = '')  : date"),(0,l.kt)("p",{parentName:"blockquote"},"Creates JavaScript ",(0,l.kt)("inlineCode",{parentName:"p"},"Date")," object based on user supplied ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate"),".")),(0,l.kt)("p",null,"This is necessary due to the way NotePlan handles dates. If you are passing a date string to any NotePlan method, you will need to first create a native JavaScript ",(0,l.kt)("inlineCode",{parentName:"p"},"date")," value."),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Date string supplied either from NotePlan directly, or from other Date Module methods. If not supplied, current date will be used")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns JavaScript ",(0,l.kt)("inlineCode",{parentName:"p"},"date")," object"))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"now"},"now"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"nowformat--string---offset--string----string"},"now(format? : string = '', offset? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns a string representation current date.")),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Note: Also available as ",(0,l.kt)("a",{parentName:"em",href:"/docs/templating-modules/date-module#helpers"},"helper")," method")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"format?")," - Desired date format. If not supplied, it will use the ",(0,l.kt)("strong",{parentName:"li"},"Date Format")," value in ",(0,l.kt)("inlineCode",{parentName:"li"},"np.Templating")," ",(0,l.kt)("a",{parentName:"li",href:"/docs/settings"},"Plugin Settings")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"offset?")," - Offset can be used to add/subtract days, months, weeks, etc. (default: 'days')")),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Shorthand Keys:"),"\nIn addition to add/subtract days, you can ",(0,l.kt)("inlineCode",{parentName:"p"},"offset")," may contain shorthand values"),(0,l.kt)("table",null,(0,l.kt)("thead",{parentName:"table"},(0,l.kt)("tr",{parentName:"thead"},(0,l.kt)("th",{parentName:"tr",align:null},"Shorthand"),(0,l.kt)("th",{parentName:"tr",align:null},"Description"))),(0,l.kt)("tbody",{parentName:"table"},(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},"y"),(0,l.kt)("td",{parentName:"tr",align:null},"years")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},"Q"),(0,l.kt)("td",{parentName:"tr",align:null},"quarters")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},"M"),(0,l.kt)("td",{parentName:"tr",align:null},"months")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},"w"),(0,l.kt)("td",{parentName:"tr",align:null},"weeks")),(0,l.kt)("tr",{parentName:"tbody"},(0,l.kt)("td",{parentName:"tr",align:null},"d"),(0,l.kt)("td",{parentName:"tr",align:null},"days")))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"-> result")," - Returns formatted date string")),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Examples")),(0,l.kt)("p",null,"The following example returns the current date, using default values"),(0,l.kt)("pre",null,(0,l.kt)("c
1ode",{parentName:"pre",className:"language-javascript"},"<%- date.now() %>\n")),(0,l.kt)("p",null,"The following example returns current date using custom format"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},'<%- date.now("dddd Do MMMM YYY") %>\n')),(0,l.kt)("p",null,"The following example will subtract 90 days"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.now('', -90) %>\n")),(0,l.kt)("p",null,"The following example will add 10 days"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.now('', 10) %>\n")),(0,l.kt)("p",null,"The following example will subtract 2 months"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.now('', '-2M') %>\n")),(0,l.kt)("p",null,"The following example will subtract 2 weeks"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.now('', '-2w') %>\n")),(0,l.kt)("p",null,"The following example will subtract 2 years"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.now('', '-2y') %>\n")),(0,l.kt)("p",null,"The following example uses the ",(0,l.kt)("inlineCode",{parentName:"p"},"now")," helper"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- now() %>\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"timestamp"},"timestamp"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"timestampformat--string----string"},"timestamp(format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns date/time timestamp with optional format")),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Note: Also available as ",(0,l.kt)("a",{parentName:"em",href:"/docs/templating-modules/date-module#helpers"},"helper")," method")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Desired date format. If not supplied, will use ",(0,l.kt)("inlineCode",{parentName:"p"},"YYYY-MM-DD h:mm A")," format")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns formatted timestamp string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Examples")),(0,l.kt)("p",null,"The following example returns the current date, using default values"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.timestamp() %>\n")),(0,l.kt)("p",null,"The following example returns current date using custom format"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},'<%- date.timestamp("dddd Do MMMM YYY") %>\n')),(0,l.kt)("p",null,"The following example uses the ",(0,l.kt)("inlineCode",{parentName:"p"},"timestamp")," helper"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- timestamp() %>\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"date8601"},"date8601"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"date8601--string"},"date8601() : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns current date 8601 format")),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Note: Also available as ",(0,l.kt)("a",{parentName:"em",href:"/docs/templating-modules/date-module#helpers"},"helper")," method")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"-> result")," - Returns current date in 8601 format")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"today"},"today"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"todayformat--string----string"},"today(format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns a string representation current date.")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Desired date format. If not supplied, it will use ",(0,l.kt)("strong",{parentName:"p"},"Date Format")," value in ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," ",(0,l.kt)("a",{parentName:"p",href:"/docs/settings"},"Plugin Settings"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following example returns the current date, using default values"),(0,l.kt)("pre",null,(0,l.kt)("c
1ode",{parentName:"pre",className:"language-javascript"},"<%- date.today() %>\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"tomorrow"},"tomorrow"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"tomorrowformat--string----string"},"tomorrow(format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns a string representation of tomorrow")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Desired date format. If not supplied, it will use the ",(0,l.kt)("strong",{parentName:"p"},"Date Format")," value in ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," ",(0,l.kt)("a",{parentName:"p",href:"/docs/settings"},"Plugin Settings"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns formatted date"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following example returns tomorrow based on current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.tomorrow() %>\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"yesterday"},"yesterday"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"yesterdayformat--string----string"},"yesterday(format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns a string representation of yesterday")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Desired date format. If not supplied, it will use the ",(0,l.kt)("strong",{parentName:"p"},"Date Format")," in ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," ",(0,l.kt)("a",{parentName:"p",href:"/docs/settings"},"Plugin Settings"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns formatted date"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following example returns yesterday based on current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.yesterday() %>\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"format"},"format"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"formatformat--string---pivotdate--string----string"},"format(format : string = '', pivotDate? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Formats ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," using supplied ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("p",null,(0,l.kt)("em",{parentName:"p"},"Note: Also available as ",(0,l.kt)("a",{parentName:"em",href:"/docs/templating-modules/date-module#helpers"},"helper")," method")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - A valid date format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to format. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns formatted date string"))),(0,l.kt)("div",{className:"admonition admonition-tip alert alert--success"},(0,l.kt)("div",{parentName:"div",className:"admonition-heading"},(0,l.kt)("h5",{parentName:"div"},(0,l.kt)("span",{parentName:"h5",className:"admonition-icon"},(0,l.kt)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"},(0,l.kt)("path",{parentName:"svg",fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"}))),"tip")),(0,l.kt)("div",{parentName:"div",className:"admonition-content"},(0,l.kt)("p",{parentName:"div"},"Refer to ",(0,l.kt)("a",{parentName:"p",href:"https://momentjs.com/docs/#/parsing/string-format/"},"moment.js format")," for available formatting options"))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"weekday"},"weekday"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"weekdayformat--string---offset--number--1-pivotdate--string----string"},"weekday(format? : string = '', offset? : number = 1, pivotDate? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns the closest weekday, using the ",(0,l.kt)("inlineCode",{parentName:"p"},"offset")," to add or subtract days")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Desired date format. If not supplied, it will use the Date Format value in ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," ",(0,l.kt)("a",{parentName:"p",href:"/docs/settings"},"Plugin Settings"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"offset?")," - Date offset, using ",(0,l.kt)("inlineCode",{parentName:"p"},"d"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"w"),", ",(0,l.kt)("inlineCode",{parentName:"p"},"m"),", or ",(0,l.kt)("inlineCode",{parentName:"p"},"y"))),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns the closest weekday 2 days in advance using current date"),(0,l.kt)("pre",null,(0,l.kt)("c
1ode",{parentName:"pre",className:"language-javascript"},"<%- date.weekday('', 2) %>\n")),(0,l.kt)("p",null,"The following returns the closest weekday 2 days in advance using fixed date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.weekday('', 2, '2021-12-15') %> // returns 2021-12-17\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"weeknumber"},"weekNumber"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"weeknumberpivotdate--string----number"},"weekNumber(pivotDate? : string = '') : number"),(0,l.kt)("p",{parentName:"blockquote"},"Returns the week number based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns week number"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns the closest weekday 2 days in advance using current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.weekNumber('2021-12-15') %> // the following will return 50\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"daynumber"},"dayNumber"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"daynumberpivotdate--string----number"},"dayNumber(pivotDate? : string = '') : number"),(0,l.kt)("p",{parentName:"blockquote"},"Returns the day number based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate"))),(0,l.kt)("p",null,"Day number will be one of following"),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"0 - Sunday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"1 - Monday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"2 - Tuesday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"3 - Wednesday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"4 - Thursday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"5 - Friday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},"6 - Saturday")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns day number"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns the closest weekday 2 days in advance using current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.dayNumber('2021-12-15') %> // the following will return 3\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"isweekday"},"isWeekday"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"isweekdaypivotdate--string----boolean"},"isWeekday(pivotDate? : string = '') : boolean"),(0,l.kt)("p",{parentName:"blockquote"},"Returns true if ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," is on weekday")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," - Returns true or false"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns true or false if ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," is weekday"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.isWeekday('2021-12-15') %> // the following will return true\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"isweekend"},"isWeekend"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"isweekendpivotdate--string----boolean"},"isWeekend(pivotDate? : string = '') : boolean"),(0,l.kt)("p",{parentName:"blockquote"},"Returns true if ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," is on weekend")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date"),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("inlineCode",{parentName:"li"},"-> result")," - Returns true or false")),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns true or false if ",(0,l.kt)("inlineCode",{parentName:"p"}
1,"pivotDate")," is weekend"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.isWeekend('2021-12-15') %> // the following will return false\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"weekof"},"weekOf"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"weekofpivotdate--string----string"},"weekOf(pivotDate? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns formatted weekOf based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted weekOf using following syntax ",(0,l.kt)("inlineCode",{parentName:"p"},"Wnn (YYYY-MM-DD..YYYY-MM-DD)")))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns weekOf value based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.weekOf('2021-12-01') %> // the following will W48 (2021-11-28..2021-12-03)\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"startofweek"},"startOfWeek"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"startofweekformat-string---pivotdate--string---firstofweek--number--0--string"},"startOfWeek(format? string = '', pivotDate? : string = '', firstOfWeek? : number = 0) : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns start of week date")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format")," - Optional date format, uses ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," Date Format if not supplied")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain start of week. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"firstOfWeek")," - Day number for first of week if not 0 (Sunday)")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns start of week"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns start of week based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.startOfWeek('2021-12-01') %> // the following return 2021-11-29\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"endofweek"},"endOfWeek"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"endofweekformat-string---pivotdate--string---firstofweek--number--0--string"},"endOfWeek(format? string = '', pivotDate? : string = '', firstOfWeek? : number = 0) : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns end of week date")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format")," - Optional date format, uses ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," Date Format if not supplied")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain end of week. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"firstOfWeek")," - Day number for first of week if not 0 (Sunday)")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns end of week"))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"startofmonth"},"startOfMonth"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"startofmonthformat-string---pivotdate--string----string"}
1,"startOfMonth(format? string = '', pivotDate? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns start of month date")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format")," - Optional date format, uses ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," Date Format if not supplied")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain start of month. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns start of month"))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"daysinmonth"},"daysInMonth"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"daysinmonthpivotdate--string----number"},"daysInMonth(pivotDate? : string = '') : number"),(0,l.kt)("p",{parentName:"blockquote"},"Returns number of days in month")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain days in month. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns days in month"))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"endofmonth"},"endOfMonth"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"endofmonthformat-string---pivotdate--string----string"},"endOfMonth(format? string = '', pivotDate? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns start of month date")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format")," - Optional date format, uses ",(0,l.kt)("inlineCode",{parentName:"p"},"np.Templating")," Date Format if not supplied")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain start of month. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns end of month"))),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"daysbetween"},"daysBetween"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"daysbetweenstartdate--string---enddate-string----number--string"},"daysBetween(startDate : string = '', endDate: string = '') : number | string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns days between two dates.")),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"startDate")," - Desired start date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"endDate")," - Desired end date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns number of days between ",(0,l.kt)("inlineCode",{parentName:"p"},"startDate")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"endDate")))),(0,l.kt)("div",{className:"admonition admonition-note alert alert--secondary"},(0,l.kt)("div",{parentName:"div",className:"admonition-heading"},(0,l.kt)("h5",{parentName:"div"},(0,l.kt)("span",{parentName:"h5",className:"admonition-icon"},(0,l.kt)("svg",{parentName:"span",xmlns:"http://www.w3.org/2000/svg",width:"14",height:"16",viewBox:"0 0 14 16"},(0,l.kt)("path",{parentName:"svg",fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"}))),"note")),(0,l.kt)("div",{parentName:"div",className:"admonition-content"},(0,l.kt)("p",{parentName:"div"},"If ",(0,l.kt)("inlineCode",{parentName:"p"},"startDate")," or ",(0,l.kt)("inlineCode",{parentName:"p"},"endDate"),' are not supplied, an error string ("Invalid Start Date" or "Invalid End Date") will be returned'))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns number of days between ",(0,l.kt)("inlineCode",{parentName:"p"},"2022-05-01")," and ",(0,l.kt)("inlineCode",{parentName:"p"},"2022-06-31")," (returns ",(0,l.kt)("inlineCode",{parentName:"p"}
1,"31"),")"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.daysBewteeen('2022-05-01', '2022-06-01') %> // returns 31\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"add"},"add"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"addnumdays--number--1-pivotdate--string---format--string----string"},"add(numDays : number = 1, pivotDate? : string = '', format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Adds ",(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," days.  You can also supply ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," and date ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," - Number of days to add (default: 1)")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Optional format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following adds 7 days, using current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.add(7, '2022-01-07') %> // returns 2022-01-14\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"businessadd"},"businessAdd"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"businessaddnumdays--number--1-pivotdate--string---format--string----string"},"businessAdd(numDays : number = 1, pivotDate? : string = '', format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Adds ",(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," business days.  You can also supply ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," and date ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," - Number of days to add (default: 1)")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Optional format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following adds 3 business days, using current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.businessAdd(3, '2022-01-07') %> // returns 2022-01-12\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"subtract"},"subtract"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"subtractnumdays--number--1-pivotdate--string---format--string----string"},"subtract(numDays : number = 1, pivotDate? : string = '', format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Subtracts ",(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," days.  You can also supply ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," and date ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," - Number of days to add (default: 1)")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to subtract from. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"}
1,"format?")," - Optional format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following subtracts 7 days, using current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.subtract(7, '2022-01-12') %> // returns 2022-01-05\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"businesssubtract"},"businessSubtract"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"businesssubtractnumdays--number--1-pivotdate--string---format--string----string"},"businessSubtract(numDays : number = 1, pivotDate? : string = '', format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Subtracts ",(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," business days.  You can also supply ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")," and date ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"numDays")," - Number of business days to subtract (default: 1)")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain subtract from. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Optional format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following subtracts 3 business days, using current date"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.businessSubtract(3, '2022-01-12') %> // returns 2022-01-07\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"nextbusinessday"},"nextBusinessDay"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"nextbusinessdaypivotdate--string---format--string----string"},"nextBusinessDay(pivotDate? : string = '', format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns next business day, based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate"),".  You can also supply date ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"format?")," - Optional format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns next business day based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.nextBusinessDay('2022-01-12') %> // returns 2022-01-13\n")),(0,l.kt)("hr",null),(0,l.kt)("h3",{id:"previousbusinessday"},"previousBusinessDay"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"previousbusinessdaypivotdate--string---format--string----string"},"previousBusinessDay(pivotDate? : string = '', format? : string = '') : string"),(0,l.kt)("p",{parentName:"blockquote"},"Returns previous business day, based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate"),".  You can also supply date ",(0,l.kt)("inlineCode",{parentName:"p"},"format"))),(0,l.kt)("ul",null,(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate?")," - Desired date to obtain week number. If not supplied, it will use current date")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"}
1,"format?")," - Optional format string")),(0,l.kt)("li",{parentName:"ul"},(0,l.kt)("p",{parentName:"li"},(0,l.kt)("inlineCode",{parentName:"p"},"-> result")," Returns formatted date string"))),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Example")),(0,l.kt)("p",null,"The following returns previous business day based on ",(0,l.kt)("inlineCode",{parentName:"p"},"pivotDate")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"<%- date.previousBusinessDay('2022-01-10') %> // returns 2022-01-07\n")),(0,l.kt)("hr",null),(0,l.kt)("h2",{id:"using-datemodule-in-noteplan-plugins"},"Using DateModule in NotePlan Plugins"),(0,l.kt)("p",null,"In addition to using the Date Module methods in templates, you can also use within your custom NotePlan plugins."),(0,l.kt)("h3",{id:"date-module-methods"},"Date Module Methods"),(0,l.kt)("p",null,"The following examples demonstrates how you can use some of the Date Module methods"),(0,l.kt)("h4",{id:"previousbusinessday-1"},"previousBusinessDay"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"// import DateModule from @templatingModules\nimport DateModule from '@templatingModules/DateModule'\n\nexport async testPreviousBusinessDay() : Promise<string> {\n    // The following example executes the `previousBusinessDay` method\n    return new DateModule().previousBusinessDay()\n}\n")),(0,l.kt)("h4",{id:"isweekend-1"},"isWeekend"),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"export async testNextBusinessDay() : Promise<string> {\n    // in addition to use the static class method, you could also create a `dateInstance` variable\n    const dateInstance = new DateModule()\n\n    // get the current date using supplied format\n    const currentDate = moment(new Date()).format('YYYY-MM-DD h:mm A')\n\n  // check if `currentDate` is weekend\n    const isWeekend = dateInstance.isWeekend(currentDate)\n  if (isWeekend) {\n        return 'Perform special handling if current day is on weekend'\n    }\n\n    return ''\n}\n")),(0,l.kt)("h2",{id:"helpers"},"Helpers"),(0,l.kt)("p",null,"DateModule exposes commonly used methods as importable helpers"),(0,l.kt)("h3",{id:"now-1"},"now"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"now---current-date"},"now() -> current date")),(0,l.kt)("h3",{id:"format-1"},"format"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"formatformat--string-----formatted-date"},"format(format : string = '') -> formatted date")),(0,l.kt)("h3",{id:"date8601-1"},"date8601"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"date8601---returns-current-date-in-8601-format"},"date8601() -> returns current date in 8601 format")),(0,l.kt)("h3",{id:"timestamp-1"},"timestamp"),(0,l.kt)("blockquote",null,(0,l.kt)("h4",{parentName:"blockquote",id:"timestamp---returns-current-date-time"},"timestamp() -> returns current date time")),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Examples:")),(0,l.kt)("pre",null,(0,l.kt)("code",{parentName:"pre",className:"language-javascript"},"// import np.Templating Library\nimport NPTemplating from 'NPTemplating'\nimport DateModule from '@templatingModules/DateModule'\nimport { now, format, timestamp, date8601 } from '@templatingModules/DateModule'\n\nconst templateData = {\n    data: {\n        testDate: new DateModule().now(), // returns current date using .now module method\n        myDate: now(), // returns current date, using default format YYYY-MM-DD\n        myDate2: date8601(), // returns current date in 8601 format YYYY-MM-DD (alias of now)\n        myDateFormatted: format('YYYY MM DD','2022-03-18'), // returns 2022 03 18\n        myTimeStamp: timestamp()\n    }\n\n    const renderedData = NPTemplating.renderTemplate('My Template', data)\n}\n")),(0,l.kt)("p",null,"\u0192"))}u.isMDXComponent=!0},9079:function(e,t,a){t.Z=a.p+"assets/images/moment-date-formats-51fb53a81a156df9ebe70ed1be8c8205.png"}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.