UNPKG

@sbh321/qcalendar

Version:

A forked version of Jeff Galbraith's fork of Quasar UI QCalendar

1,520 lines 47.6 kB
{ "type": "util", "meta": { "docsUrl": "https://quasarframework.github.io/quasar-ui-qcalendar/docs" }, "methods": { "today": { "addedIn": "v2.2.1", "desc": "Returns today's date in YYYY-MM-DD format", "returns": { "type": "String", "desc": "Returns today's date in YYYY-MM-DD format" } }, "getStartOfWeek": { "desc": "Returns the start of the week based on the passed in arguments", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object", "required": true }, "weekdays": { "type": "Array", "tsType": "NumberArray", "desc": "The normal weekdays array looks like this `[0,1,2,3,4,5,6]` where 0=Sunday, 1=Monday, etc. A week that starts on Monday, would look like this: `[1,2,3,4,5,6,0]` and a 5-day workweek would look like this: `[1,2,3,4,5]`", "required": true, "examples": [ "[0,1,2,3,4,5,6]", "[1,2,3,4,5,6,0]", "[1,2,3,4,5]" ] }, "today": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object that represents 'today' or a specified point in time. If passed in, then the relative information to the start-of-week timestamp object will be updated", "default": "undefined" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object representing the start of the week" } }, "getEndOfWeek": { "desc": "Returns the end of the week based on the passed in arguments", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object", "required": true }, "weekdays": { "type": "Array", "tsType": "NumberArray", "desc": "The normal weekdays array looks like this `[0,1,2,3,4,5,6]` where 0=Sunday, 1=Monday, etc. A week that starts on Monday, would look like this: `[1,2,3,4,5,6,0]` and a 5-day workweek would look like this: `[1,2,3,4,5]`", "required": true, "examples": [ "[0,1,2,3,4,5,6]", "[1,2,3,4,5,6,0]", "[1,2,3,4,5]" ] }, "today": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object that represent 'today' or a specified point in time. If passed in, then the relative information to the end-of-week timestamp object will be updated", "default": "undefined" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object representing the end of the week" } }, "getStartOfMonth": { "desc": "Returns the start of the month based on the passed in timestamp object", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object representing the start of the month" } }, "getEndOfMonth": { "desc": "Returns the end of the month based on the passed in timestamp object", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object representing the end of the month" } }, "parseTime": { "desc": "Parses the passed in value and returns the number of minutes since midnight", "params": { "input": { "type": [ "Number", "String", "Object" ], "tsType": "TimeObjectOrNumberOrString", "required": true, "desc": "Value may be a Number (minutes since midnight) or String (hh:mm:ss where seconds are optional) or Object (must have keys **hour** and **minute**)", "examples": [ "600", "15:30", "{ hour: 15, minute: 30 }" ] } }, "returns": { "type": "Number", "desc": "The number of minutes since midnight" } }, "validateTimestamp": { "desc": "Validates the passed in date/time string (YYYY-MM-DD hh:mm:ss)", "params": { "input": { "type": "String", "required": true, "desc": "A date/time string in the form `YYYY-MM-DD hh:mm:ss` (seconds are optional)", "examples": [ "2020-10-02 15:00" ] } }, "returns": { "type": "Boolean", "desc": "True if the passed in date/time string is of correct form" } }, "parsed": { "desc": "Parses a date/time string to a simple timestamp object. For a more complete timestamp, use parseTimestamp", "params": { "input": { "type": "String", "required": true, "desc": "A date/time string in the form `YYYY-MM-DD hh:mm:ss` (seconds are optional)", "examples": [ "2020-10-02 15:00" ] } }, "returns": { "type": [ "Object", "null" ], "tsType": "TimestampOrNull", "desc": "A timestamp object based on the passed in argument. Returns 'null' on error" } }, "parseTimestamp": { "desc": "Parses a date/time string to the timestamp object. Very similar to the `parsed` method, except also updates timestamp with formatted and relative information", "params": { "input": { "type": "String", "required": true, "desc": "A date/time string in the form `YYYY-MM-DD hh:mm:ss` (seconds are optional)", "examples": [ "2020-10-02 15:00" ] }, "now": { "type": "Object", "tsType": "TimestampOrNull", "desc": "[Optional] A Timestamp object. If provided, the returning Timestamp will have formatted and relative information included" } }, "returns": { "type": [ "Object", "null" ], "tsType": "TimestampOrNull", "desc": "A timestamp object based on the passed in argument. Returns 'null' on error" } }, "parseDate": { "desc": "Parses a JavaScript Date object to the timestamp object", "params": { "input": { "type": "Date", "required": true, "desc": "A JavaScript Date object" } }, "returns": { "type": [ "Object", "null" ], "tsType": "TimestampOrNull", "desc": "A formatted timestamp object based on the passed in argument (see updateFormatted)" } }, "makeDate": { "addedIn": "v1.3.9", "desc": "Takes a timestamp and returns a JavaScript Date with time set to 00:00", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Date", "desc": "The returned value is a JavaScript Date" } }, "makeDateTime": { "addedIn": "v1.3.9", "desc": "Takes a timestamp and returns a JavaScript Date", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Date", "desc": "The returned value is a JavaScript Date" } }, "getDayIdentifier": { "desc": "Turns passed in timestamp object to a day identifier", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Number", "desc": "The returned number is in a number representing `YYYYMMdd`" } }, "getTimeIdentifier": { "desc": "Turns passed in timestamp object to a time identifier", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Number", "desc": "The returned number is in a number representing `hhmm`" } }, "getDayTimeIdentifier": { "desc": "Turns passed in timestamp object to a date/time identifier", "addedIn": "v3.2.0", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Number", "desc": "The returned number is in a number representing `YYYYMMddhhmm`" } }, "diffTimestamp": { "desc": "Returns the number of milliseconds between the two days", "params": { "timestamp1": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "timestamp2": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "strict": { "type": "Boolean", "desc": "If true, then negative values are not allowed", "required": true } }, "returns": { "type": "Number", "desc": "The number of milliseconds between the two timestamp objects. 0 if **strict** is true and the value would be negative" } }, "updateRelative": { "desc": "Updates the relative information in the timestamp object. The relative information includes, compared to the **now** object, `past`, `current` and `future` booleans", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "now": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object representing a **now** time (fixed point in time -- usually **today**)" }, "time": { "type": "Boolean", "desc": "If true, also uses time to adjust the relative information", "default": false } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "updateMinutes": { "desc": "Updates the timestamp object with the passed in minutes", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "minutes": { "type": "Number", "required": true, "desc": "The number of minutes since midnight" }, "now": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object, if set, used to adjust the relative information", "default": "undefined" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "updateWeekday": { "desc": "Updates the timestamp object with the weekday information", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "updateDayOfYear": { "desc": "Updates the timestamp object with the doy (day of year) information", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "updateWorkWeek": { "desc": "Updates the timestamp object with the workweek (work week) information", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "updateDisabled": { "desc": "Updates the timestamp object to be disabled if it matches one of the items from `disabledDays`", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "disabledBefore": { "type": "String", "desc": "A date in the form `YYYY-MM-DD` where all dates before, and including, will be disabled" }, "disabledAfter": { "type": "String", "desc": "A date in the form `YYYY-MM-DD` where all dates after, and including, will be disabled" }, "disabledWeekdays": { "type": "Array", "tsType": "NumberArray", "default": "[]", "desc": "An array of numbers representing the weekdays, where 0=Sunday to 6=Saturday", "examples": [ "[0,6] - this disables the weekend" ] }, "disabledDays": { "type": "Array", "tsType": "StringArray", "desc": "An array of disabled days. If an array is contained within the array with a start and end date, it will be treated as a range", "examples": [ "['2020-01-01', '2020-07-04']", "['2020-01-01', ['2020-07-04', '2020-07-11']]" ] } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object with `timestamp.disabled` true if a match was found" } }, "updateFormatted": { "desc": "Updates the timestamp object with formatted information (`time`, `date`, `weekday`, `doy` and `workweek`)", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "getDayOfYear": { "desc": "Returns the doy (day of year) for an unformatted timestamp", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Number", "desc": "The day of the year" } }, "getWorkWeek": { "desc": "Returns the workweek (work week number) for an unformatted timestamp", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": false, "desc": "A timestamp object. If no timestamp is passed, then uses current date" } }, "returns": { "type": "Number", "desc": "The work week number of the year. If passed an invalid date, the return value is always 0" } }, "getWeekday": { "desc": "Returns the weekday (day of the week) for an unformatted timestamp", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Number", "desc": "The week day number (0=Sunday, 1=Monday, etc)" } }, "isLeapYear": { "desc": "Returns true if the passed in year is a leap year", "params": { "year": { "type": "Number", "required": true, "desc": "A number representing the year in YYYY format", "examples": [ "2020", "2021" ] } }, "returns": { "type": "Boolean", "desc": "Returns true if the passed in year is a leap year" } }, "daysInMonth": { "desc": "Returns number of days in the spefified month for the specified year (takes into account leap years)", "params": { "year": { "type": "Number", "required": true, "desc": "A number representing the year in YYYY format", "examples": [ "2020", "2021" ] }, "month": { "type": "Number", "required": true, "desc": "A number representing the month from 0 (January) to 11 (December). For performance reasons, no checking is done to validate this value is in range. An exception will occur if it is not", "examples": [ "2020", "2021" ] } }, "returns": { "type": "Number", "desc": "Returns true if the passed in year is a leap year" } }, "copyTimestamp": { "desc": "Makes a copy of the passed Timestamp", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object", "required": true } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A copy of the passed in timestamp object" } }, "compareTimestamps": { "desc": "Compares two timestamps", "params": { "timestamp1": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "timestamp2": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Boolean", "desc": "true if timestamps are the same, otherwise false" } }, "compareDate": { "desc": "Compares two timestamps if the dates are the same", "params": { "timestamp1": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "timestamp2": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Boolean", "desc": "true if timestamps dates are the same, otherwise false" } }, "compareTime": { "desc": "Compares two timestamps if the times are the same", "params": { "timestamp1": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "timestamp2": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Boolean", "desc": "true if timestamps times are the same, otherwise false" } }, "compareDateTime": { "desc": "Compares two timestamps if the dates and times are the same", "params": { "timestamp1": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "timestamp2": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Boolean", "desc": "true if timestamps dates and times are the same, otherwise false" } }, "padNumber": { "desc": "Pads the passed in number to the specfied length. Passing in `(2,2)` returns `02`", "params": { "x": { "type": "Number", "desc": "The number to pad", "required": true }, "length": { "type": "Number", "desc": "The length of the paddedIng", "required": true } }, "returns": { "type": "String", "desc": "A padded value" } }, "getDate": { "desc": "Returns the timestamp as a padded date", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "String", "desc": "A date as a padded value in the form `YYYY-MM-DD`. Instead of `2020-1-2`, this function formats it as `2020-01-02`" } }, "getTime": { "desc": "Returns the timestamp as a padded time", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "String", "desc": "A time as a padded value in the form `hh:mm`. Instead of `2:3`, this function formats it as `02:03`" } }, "getDateTime": { "addedIn": "v1.3.11", "desc": "Returns the timestamp as a padded date and time. If time is not available, then only the date will be used", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "String", "desc": "A date and time as a padded value in the form `YYYY-MM-DD hh:mm`. Instead of `2020-1-2 1:20`, this function formats it as `2020-01-02 01:20`" } }, "nextDay": { "desc": "Returns the timestamp set to the next day, updating month and year if needed", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object incremented to the next day" } }, "prevDay": { "desc": "Returns the timestamp set to the previous day, updating month and year if needed", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object decremented to the next day" } }, "relativeDays": { "desc": "Returns the timestamp set to the relative day", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "mover": { "type": "Function", "tsType": "TimestampMoveOperation", "default": "nextDay", "values": [ "prevDay", "nextDay" ], "desc": "A reference that points to a function that handles the relative movement from one date to another. If moving backwards, specify `prevDay`", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "days": { "type": "Number", "default": 1, "desc": "The number of days to move" }, "allowedWeekdays": { "type": "Array", "tsType": "NumberArray", "default": "[0,1,2,3,4,5,6]", "desc": "The allow weekdays to use. The method uses this information for allowed days", "examples": [ "[0,1,2,3,4,5,6]", "[1,2,3,4,5,6,0]", "[1,2,3,4,5]" ] } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object moved to the relatively specified days against the `allowedWeekdays`" } }, "moveRelativeDays": { "desc": "Returns the timestamp set to the relative day, takes into account allowed weekdays", "addedIn": "v1.5.0", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "mover": { "type": "Function", "tsType": "TimestampMoveOperation", "default": "nextDay", "values": [ "prevDay", "nextDay" ], "desc": "A reference that points to a function that handles the relative movement from one date to another. If moving backwards, specify `prevDay`", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "days": { "type": "Number", "default": 1, "desc": "The number of days to move" }, "allowedWeekdays": { "type": "Array", "tsType": "NumberArray", "default": "[0,1,2,3,4,5,6]", "desc": "The allow weekdays to use. The method uses this information for allowed days", "examples": [ "[0,1,2,3,4,5,6]", "[1,2,3,4,5,6,0]", "[1,2,3,4,5]" ] } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object moved to the relatively specified days against the `allowedWeekdays`" } }, "findWeekday": { "desc": "Returns the timestamp associated to the specified weekday. Use `parseTimestamp`, not `parsed` (or manually call `updateFormatted` before calling this method), so associated fields are updated correctly, otherwise this function will not work as expected.", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "mover": { "type": "Function", "tsType": "TimestampMoveOperation", "default": "nextDay", "values": [ "prevDay", "nextDay" ], "desc": "A reference that points to a function that handles the relative movement from one date to another. If moving backwards, specify `prevDay`", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" } }, "maxDays": { "type": "Number", "default": 6, "desc": "The maxiumum number of days to move" } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object moved to the specified days relatively against the `maxDays`" } }, "getWeekdaySkips": { "desc": "Returns the weekday skips in an array of 0's (off) and 1's (on). Basically, can convert `[1,2,3,4,5]` to `[0,1,1,1,1,1,0]`", "params": { "weekdays": { "type": "Array", "tsType": "NumberArray", "desc": "The normal weekdays array looks like this `[0,1,2,3,4,5,6]` where 0=Sunday, 1=Monday, etc. A week that starts on Monday, would look like this: `[1,2,3,4,5,6,0]` and a 5-day workweek would look like this: `[1,2,3,4,5]`", "required": true, "examples": [ "[0,1,2,3,4,5,6]", "[1,2,3,4,5,6,0]", "[1,2,3,4,5]" ] } }, "returns": { "type": "Array", "tsType": "NumberArray", "desc": "An array of 7 (representing a week) of 0's (hidden) and 1's (displayed)" } }, "createDayList": { "desc": "Returns an array of timestamps", "params": { "start": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "end": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "now": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object" }, "weekdaySkips": { "type": "Object", "tsType": "NumberArray", "required": true, "desc": "An array of 7 numbers (representing 7 days of the week) that are either a 1 or 0" }, "disabledBefore": { "type": "String", "desc": "A date in the form `YYYY-MM-DD` where all dates before, and including, will be disabled" }, "disabledAfter": { "type": "String", "desc": "A date in the form `YYYY-MM-DD` where all dates after, and including, will be disabled" }, "disabledWeekdays": { "type": "Array", "tsType": "NumberArray", "default": "[]", "desc": "An array of numbers representing the weekdays, where 0=Sunday to 6=Saturday", "examples": [ "[0,6] - this disables the weekend" ] }, "disabledDays": { "type": "Array", "tsType": "StringArray", "default": "[]", "desc": "An array of string dates in the form `YYYY-MM-DD` that representing disabled days" }, "max": { "type": "Number", "default": "42", "desc": "Maximum days required. 42 is the maxiumum number of days in a full calendar month (6 rows) with `outside` days" }, "min": { "type": "Number", "default": "0", "desc": "Minimum days required" } }, "returns": { "type": "Array", "tsType": "TimestampArray", "desc": "An array of timestamp objects for all days that meet the criteria" } }, "createIntervalList": { "desc": "Returns an array of intervals", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object representing the day for the intervals" }, "first": { "type": "Number", "required": true, "desc": "The first interval" }, "minutes": { "type": "Number", "required": true, "desc": "The number of minutes in an interval" }, "count": { "type": "Number", "required": true, "desc": "The count of intervals requested" }, "now": { "type": "Object", "tsType": "Timestamp", "required": true, "desc": "A timestamp object that represents 'today' or a specified point in time" } }, "returns": { "type": "Array", "tsType": "TimestampArray", "desc": "A array of interval objects (timestamps with time) that meet the criteria" } }, "createNativeLocaleFormatter": { "desc": "Returns a function to be used for international date formatting purposes", "params": { "local": { "type": "String", "required": true, "desc": "A string representing the locale to use (ie: en-US for America)" }, "getOptions": { "type": "Function", "tsType": "TimestampFormatOptions", "required": true, "desc": "A function that passes the timestamp and a boolean", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object" }, "short": { "type": "Boolean", "desc": "if true, specifies to use the short version (ie: 'Monday' to be returns as 'Mon', 'January' to be returned as 'Jan', etc)" } }, "returns": { "type": "Object", "tsType": "TimestampFormatter", "desc": "This uses the Intl.DateTimeFormat function of the browser. Options are specified [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)", "examples": [ "{ timeZone: 'UTC', month: 'long' }", "{ timeZone: 'UTC', month: 'short' }", "{ timeZone: 'UTC', weekday: 'long' }", "{ timeZone: 'UTC', weekday: 'short' }" ] } } }, "returns": { "type": "String", "desc": "The output of the operation" } }, "validateNumber": { "desc": "Validates that input is a number", "params": { "input": { "type": [ "Number", "String" ], "required": true, "desc": "A numeric value", "examples": [ "validateNumber(10) // true", "validateNumber('10') // true", "validateNumber('bob') // false" ] } }, "returns": { "type": "Boolean", "desc": "true if a number, otherwise false" } }, "maxTimestamp": { "desc": "Given an array of Timestamps, returns the highest one", "params": { "timestamps": { "type": "Object", "tsType": "TimestampArray", "desc": "An array of timestamp objects", "required": true }, "useTime": { "type": "Boolean", "desc": "[Optional] Use time in the comparison", "default": false } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "The highest valued Timestamp" } }, "minTimestamp": { "desc": "Given an array of Timestamps, returns the lowest one", "params": { "timestamps": { "type": "Object", "tsType": "TimestampArray", "desc": "An array of timestamp objects", "required": true }, "useTime": { "type": "Boolean", "desc": "[Optional] Use time in the comparison", "default": false } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "The highest valued Timestamp" } }, "isBetweenDates": { "addedIn": "v1.3.10", "desc": "Checks passed timestamp is between start and end timestamps", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object", "required": true }, "startTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The starting timestamp object to use for the comparison", "required": true }, "endTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The ending timestamp object to use for the comparison", "required": true }, "useTime": { "type": "Boolean", "desc": "[Optional] Use time in the comparison", "default": false } }, "returns": { "type": "Boolean", "desc": "true if a date is between the start and end dates" } }, "isOverlappingDates": { "addedIn": "v1.3.12", "desc": "Checks passed start and end timestamps overlap the first and last timestamps. This method can be used to find if an event, with start and end dates overlap a range, like a week", "examples": [ "isOverlappingDates(parsed('2020-01-01'), parsed('2020-01-10'), parsed('2019-12-29'), parsed('2020-01-04')) === true", "isOverlappingDates(parsed('2020-01-01'), parsed('2020-01-10'), parsed('2020-01-29'), parsed('2020-01-30')) === false" ], "params": { "startTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The starting timestamp object to use for the comparison", "required": true }, "endTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The ending timestamp object to use for the comparison", "required": true }, "firstTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The first timestamp object to use for the comparison (typically the first day in a week)", "required": true }, "lastTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The last timestamp object to use for the comparison (typically the last day in a week)", "required": true } }, "returns": { "type": "Boolean", "desc": "true if the start and end timestamps overlap the first and last timestamps" } }, "daysBetween": { "addedIn": "v1.3.12", "desc": "Returns the number days between two timestamps", "params": { "startTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The starting timestamp object to use for the comparison", "required": true }, "endTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The ending timestamp object to use for the comparison", "required": true } }, "returns": { "type": "Number", "desc": "The number of days beween the two timestamps" } }, "weeksBetween": { "addedIn": "v1.3.12", "desc": "Returns the number weeks between two timestamps", "params": { "startTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The starting timestamp object to use for the comparison", "required": true }, "endTimestamp": { "type": "Object", "tsType": "Timestamp", "desc": "The ending timestamp object to use for the comparison", "required": true } }, "returns": { "type": "Number", "desc": "The number of weeks beween the two timestamps" } }, "addToDate": { "addedIn": "v1.3.10", "desc": "Takes a timestamp and increments/decrements based on options", "params": { "timestamp": { "type": "Object", "tsType": "Timestamp", "desc": "A timestamp object", "required": true }, "options": { "type": "Object", "tsType": "AddToDateOptions", "desc": "The options passed to the method. All items are optional and can be positive or negative", "required": true, "examples": [ "{ year: 1, month: -1, day: 10, hour: 2, minute: 3 }", "{ month: -1 }", "{ day: 3 }", "{ hour: 10 }", "{ minute: 10000 }" ], "definition": { "year": { "type": [ "Number", "String" ], "desc": "[Optional] The amount to increment/decrement the year", "examples": [ "{ year: 1 }", "{ year: '-1' }" ] }, "month": { "type": [ "Number", "String" ], "desc": "[Optional] The amount to increment/decrement the month", "examples": [ "{ month: 1 }", "{ month: '-1' }" ] }, "day": { "type": [ "Number", "String" ], "desc": "[Optional] The amount to increment/decrement the day", "examples": [ "{ day: 1 }", "{ day: '-1' }" ] }, "hour": { "type": [ "Number", "String" ], "desc": "[Optional] The amount to increment/decrement the hour", "examples": [ "{ hour: 1 }", "{ hour: '-1' }" ] }, "minute": { "type": [ "Number", "String" ], "desc": "[Optional] The amount to increment/decrement the minute", "examples": [ "{ minute: 1 }", "{ minute: '-1' }" ] } } } }, "returns": { "type": "Object", "tsType": "Timestamp", "desc": "A copy of the modified timestamp object with the applied options", "examples": [ "const ts1 = addToDate(timestamp, { hour: 1 })", "const ts2 = addToDate(timestamp, { month: 3, hour: -1 })" ] } }, "getWeekdayFormatter": { "desc": "Returns a function to be used for international formatting purposes for the weekday", "returns": { "type": "Function", "tsType": "WeekdayFormatter", "desc": "This uses the Intl.DateTimeFormat function of the browser", "params": { "weekday": { "type": "String", "required": true, "values": [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], "desc": "The values represent the day of the week (in short form, Pascal-case) in English, but used to translate to the desired locale" }, "type": { "type": "String", "default": "long", "values": [ "long", "short", "narrow" ], "desc": "The values represent how the day of the week will be displayed" }, "locale": { "type": "String", "default": "en-US", "desc": "Any locale accepted by the browser can be used" } }, "returns": { "type": "String", "desc": "The formatted string of the specified weekday in the desired locale" }, "examples": [ "weekdayFormatter('Mon')", "weekdayFormatter('Sun', 'long', 'de')", "weekdayFormatter('Fri', 'short', 'fr')", "weekdayFormatter('Sat', 'narrow', 'fi')" ] } }, "getWeekdayNames": { "desc": "Returns an array of localized weekday names in either 'long', 'short', or 'narrow' format", "params": { "type": { "type": "String", "default": "long", "values": [ "long", "short", "narrow" ], "desc": "The values represent how the day of the week will be displayed" }, "locale": { "type": "String", "default": "en-US", "desc": "Any locale accepted by the browser can be used" } }, "returns": { "type": "Array", "tsType": "StringArray", "desc": "An array of localized weekday names", "examples": [ "[ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]", "[ 'vuos', 'maŋ', 'gask', 'duor', 'bear', 'láv', 'sotn' ]" ] }, "examples": [ "getWeekdayNames('long', 'en-US')", "getWeekdayNames('short', 'se')", "getWeekdayNames('narrow', 'de')" ] }, "getMonthFormatter": { "desc": "Returns a function to be used for international formatting purposes for the month", "returns": { "type": "Function", "tsType": "MonthFormatter", "desc": "This uses the Intl.DateTimeFormat function of the browser", "params": { "month": { "type": "Number", "required": true, "desc": "The values 0-11 can be used to represent the month (0-based) and used to translate to the desired locale" }, "type": { "type": "String", "default": "long", "values": [ "long", "short", "narrow" ], "desc": "The values represent how the month will be displayed" }, "locale": { "type": "String", "default": "en-US", "desc": "Any locale accepted by the browser can be used" } }, "returns": { "type": "String", "desc": "The formatted string of the specified month in the desired locale" }, "examples": [ "monthFormatter('Mon')", "monthFormatter('Sun', 'long', 'de')", "monthFormatter('Fri', 'short', 'fr')", "monthFormatter('Sat', 'narrow', 'fi')" ] } }, "getMonthNames": { "desc": "Returns an array of localized month names in either 'long', 'short', or 'narrow' format", "params": { "type": { "type": "String", "default": "long", "values": [ "long", "short", "narrow" ], "desc": "The values represent how the day of the month will be displayed" }, "locale": { "type": "String", "default": "en-US", "desc": "Any locale accepted by the browser can be used" } }, "returns": { "type": "Array", "tsType": "StringArray", "desc": "An array of localized month names", "examples": [ "[ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]", "[ 'ođđj', 'guov', 'njuk', 'cuo', 'mies', 'geas', 'suoi', 'borg', 'čakč', 'golg', 'skáb', 'juov' ]" ] }, "examples": [ "getMonthNames('long', 'en-US')", "getMonthNames('short', 'se')", "getMonthNames('narrow', 'de')" ] } } }