@compute.ts/date
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Presentation

The engine is based on incremental computation algorithms. When a calculation is submitted to the engine, all the computed values are memorized. So, if you change some variable and query an evaluation, the engine is able to compute the result very fast because it recomputes only what has changed.

compute.ts

Libraries

The project provides several libraries that each comes with dozens of operators. Please note the cross-compatibility of the libraries.

Imports

Typescript

import {/* required operators */} from '@compute.ts/date';

Javascript

const {/* required operators */} = require('@compute.ts/date');

Operators

date

date(value) ➜ xdate

date() ➜ xdate

The boolean operator allows you to create a boolean expression which evals to the given value. If no value is provided the expression is a variable of the model

import {date} from "@compute.ts/date"

const x = date(new Date('05/08/1992'));
x.affect(new Date('16/03/1996'))

parseDate

parseDate(xstring) ➜ xdate

The parseDate operator allows you to create a date expression which evals to the given value.

import {parseDate} from "@compute.ts/date"

const x = parseDate('April 1, 1992');

const value = x.eval();

isSame

isSame(xdate, ydate) ➜ zboolean
xdate.isSame(ydate) ➜ zboolean

The isSame operator allows to create a boolean expression which evals the true if x is the same date as y

import {date, isSame} from "@compute.ts/date"

const x = date();  
const y = date();  
const z = isSame(x, y) | x.isSame(y);

const value = z.eval();

isNotSame

isNotSame(xdate, ydate) ➜ zboolean
xdate.isNotSame(ydate) ➜ zboolean

The isNotSame operator allows to create a boolean expression which evals the true if x is not the same date as y

import {date, isNotSame} from "@compute.ts/date"

const x = date();  
const y = date();  
const z = isNotSame(x, y) | x.isNotSame(y);

const value = z.eval();

setDate

setDate(xdate, ynumber) ➜ zdate
xdate.setDate(ynumber) ➜ zdate

The setDay operator allows to create a date expression which evals to x where the date has been changed

import {number} from "@compute.ts/number";  
import {date, setDate} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = setDate(x, y) | x.setDate(y);

const value = z.eval();

setMonth

setMonth(xdate, ynumber) ➜ zdate
xdate.setMonth(ynumber) ➜ zdate

The setMonth operator allows to create a date expression which evals to x where the month has been changed

import {number} from "@compute.ts/number";  
import {date, setMonth} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = setMonth(x, y) | x.setMonth(y);

const value = z.eval();

setYear

setYear(xdate, ynumber) ➜ zdate
xdate.setYear(ynumber) ➜ zdate

The setYear operator allows to create a date expression which evals to x where the year has been changed

import {number} from "@compute.ts/number";  
import {date, setYear} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = setYear(x, y) | x.setYear(y);

const value = z.eval();

addDay

addDay(xdate, ynumber) ➜ zdate
xdate.addDay(ynumber) ➜ zdate

The addDay operator allows to create a date expression which evals the date x but y day(s) later

import {number} from "@compute.ts/number";  
import {date, addDay} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = addDay(x, y) | x.addDay(y);

const value = z.eval();

addMonth

addMonth(xdate, ynumber) ➜ zdate
xdate.addMonth(ynumber) ➜ zdate

The addMonth operator allows to create a date expression which evals the date x but y month(s) later

import {number} from "@compute.ts/number";  
import {date, addMonth} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = addMonth(x, y) | x.addMonth(y);

const value = z.eval();

addYear

addYear(xdate, ynumber) ➜ zdate
xdate.addYear(ynumber) ➜ zdate

The addYear operator allows to create a date expression which evals the date x but y year(s) later

import {number} from "@compute.ts/number";  
import {date, addYear} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = addYear(x, y) | x.addYear(y);

const value = z.eval();

minusDay

minusDay(xdate, ynumber) ➜ zdate
xdate.minusDay(ynumber) ➜ zdate

The minusDay operator allows to create a date expression which evals the y day(s) before x

import {number} from "@compute.ts/number";  
import {date, minusDay} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = minusDay(x, y) | x.minusDay(y);

const value = z.eval();

minusMonth

minusMonth(xdate, ynumber) ➜ zdate
xdate.minusMonth(ynumber) ➜ zdate

The minusMonth operator allows to create a date expression which evals the y month(s) before x

import {number} from "@compute.ts/number";  
import {date, minusMonth} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = minusMonth(x, y) | x.minusMonth(y);

const value = z.eval();

²


minusYear

minusYear(xdate, ynumber) ➜ zdate
xdate.minusYear(ynumber) ➜ zdate

The minusYear operator allows to create a date expression which evals the y year(s) before x

import {number} from "@compute.ts/number";  
import {date, minusYear} from "@compute.ts/date"

const x = date();  
const y = number();  
const z = minusYear(x, y) | x.minusYear(y);

const value = z.eval();

getDay

getDay(xdate) ➜ ynumber
xdate.getDay() ➜ ynumber

The getDay operator allows to create a date expression which evals the date of x (x ∈ [0, 6])

import {date, getDay} from "@compute.ts/date"

const x = date();  
const y = getDay(x) | x.getDay();

const value = y.eval();

getDate

getDate(xdate) ➜ ynumber
xdate.getDate() ➜ ynumber

The getDate operator allows to create a date expression which evals the date of x (x ∈ [0, 30])

import {date, getDate} from "@compute.ts/date"

const x = date();  
const y = getDate(x) | x.getDate();

const value = y.eval();

getMonth

getMonth(xdate) ➜ ynumber
xdate.getMonth() ➜ ynumber

The getMonth operator allows to create a date expression which evals the month of x (x ∈ [0, 11])

import {date, getMonth} from "@compute.ts/date"

const x = date();  
const y = getMonth(x) | x.getMonth();

const value = y.eval();

getYear

getYear(xdate) ➜ ynumber
xdate.getYear() ➜ ynumber

The getYear operator allows to create a date expression which evals the year of x

import {date, getYear} from "@compute.ts/date"

const x = date();  
const y = getYear(x) | x.getYear();

const value = y.eval();

getWeek

getWeek(xdate) ➜ ynumber
xdate.getWeek() ➜ ynumber

The getWeek operator allows to create a date expression which evals the week of x (x ∈ [0, 51])

import {date, getWeek} from "@compute.ts/date"

const x = date();  
const y = getWeek(x) | x.getWeek();

const value = y.eval();

toString

toString(xdate) ➜ zstring
xdate.toString() ➜ zstring

import {date, toString} from "@compute.ts/date"

const x = date();  
const y = toString(x) | x.toString();

const value = y.eval();

isLeapYear

isLeapYear(xdate) ➜ yboolean
xdate.isLeapYear() ➜ yboolean

The isLeapYear operator allows to create a boolean expression which evals the true if x a leap year

import {date, isLeapYear} from "@compute.ts/date"

const x = date();  
const y = isLeapYear(x) | x.isLeapYear();

const value = y.eval();

isWeekend

isWeekend(xdate) ➜ yboolean
xdate.isWeekend() ➜ yboolean

The isWeekEnd operator allows to create a boolean expression which evals the true if x a weekend day

import {date, isWeekend} from "@compute.ts/date"

const x = date();  
const y = isWeekend(x) | x.isWeekEnd();

const value = y.eval();

isWeek

isWeek(xdate) ➜ yboolean
xdate.isWeek() ➜ yboolean

The isWeek operator allows to create a boolean expression which evals the true if x is a week day

import {date, isWeek} from "@compute.ts/date"

const x = date();  
const y = isWeek(x) | x.isWeek();

const value = y.eval();

isMonday

isMonday(xdate) ➜ yboolean
xdate.isMonday() ➜ yboolean

The isMonday operator allows to create a boolean expression which evals the true if x is monday

import {date, isMonday} from "@compute.ts/date"

const x = date();  
const y = isMonday(x) | x.isMonday();

const value = y.eval();

isTuesday

isTuesday(xdate) ➜ yboolean
xdate.isTuesday() ➜ yboolean

The isTuesday operator allows to create a boolean expression which evals the true if x is in tuesday

import {date, isTuesday} from "@compute.ts/date"

const x = date();  
const y = isTuesday(x) | x.isTuesday();

const value = y.eval();

isWednesday

isWednesday(xdate) ➜ yboolean
xdate.isWednesday() ➜ yboolean

The isWednesday operator allows to create a boolean expression which evals the true if x is in wednesday

import {date, isWednesday} from "@compute.ts/date"

const x = date();  
const y = isWednesday(x) | x.isWednesday();

const value = y.eval();

isThursday

isThursday(xdate) ➜ yboolean
xdate.isThursday() ➜ yboolean

The isThursday operator allows to create a boolean expression which evals the true if x is thursday

import {date, isThursday} from "@compute.ts/date"

const x = date();  
const y = isThursday(x) | x.isThursday();

const value = y.eval();

isFriday

isFriday(xdate) ➜ yboolean
xdate.isFriday() ➜ yboolean

The isFriday operator allows to create a boolean expression which evals the true if x is friday

import {date, isFriday} from "@compute.ts/date"

const x = date();  
const y = isFriday(x) | x.isFriday();

const value = y.eval();

isSaturday

isSaturday(xdate) ➜ yboolean
xdate.isSaturday() ➜ yboolean

The isSaturday operator allows to create a boolean expression which evals the true if x is in saturday

import {date, isSaturday} from "@compute.ts/date"

const x = date();  
const y = isSaturday(x) | x.isSaturday();

const value = y.eval();

isSunday

isSunday(xdate) ➜ yboolean
xdate.isSunday() ➜ yboolean

The isSunday operator allows to create a boolean expression which evals the true if x is sunday

import {date, isSunday} from "@compute.ts/date"

const x = date();  
const y = isSunday(x) | x.isSunday();

const value = y.eval();

isJanuary

isJanuary(xdate) ➜ yboolean
xdate.isJanuary() ➜ yboolean

The isJanuary operator allows to create a boolean expression which evals the true if x is in january

import {date, isJanuary} from "@compute.ts/date"

const x = date();  
const y = isJanuary(x) | x.isJanuary();

const value = y.eval();

isFebuary

isFebuary(xdate) ➜ yboolean
xdate.isFebuary() ➜ yboolean

The isFebuary operator allows to create a boolean expression which evals the true if x is in febuary

import {date, isFebuary} from "@compute.ts/date"

const x = date();  
const y = isFebuary(x) | x.isFebuary();

const value = y.eval();

isMarch

isMarch(xdate) ➜ yboolean
xdate.isMarch() ➜ yboolean

The isMarch operator allows to create a boolean expression which evals the true if x is in march

import {date, isMarch} from "@compute.ts/date"

const x = date();  
const y = isMarch(x) | x.isMarch();

const value = y.eval();

isApril

isApril(xdate) ➜ yboolean
xdate.isApril() ➜ yboolean

The isApril operator allows to create a boolean expression which evals the true if x is in april

import {date, isApril} from "@compute.ts/date"

const x = date();  
const y = isApril(x) | x.isApril();

const value = y.eval();

isMay

isMay(xdate) ➜ yboolean
xdate.isMay() ➜ yboolean

The isMay operator allows to create a boolean expression which evals the true if x is in may

import {date, isMay} from "@compute.ts/date"

const x = date();  
const y = isMay(x) | x.isMay();

const value = y.eval();

isJune

isJune(xdate) ➜ yboolean
xdate.isJune() ➜ yboolean

The isJune operator allows to create a boolean expression which evals the true if x is in june

import {date, isJune} from "@compute.ts/date"

const x = date();  
const y = isJune(x) | x.isJune();

const value = y.eval();

isJuly

isJuly(xdate) ➜ yboolean
xdate.isJuly() ➜ yboolean

The isJuly operator allows to create a boolean expression which evals the true if x is in july

import {date, isJuly} from "@compute.ts/date"

const x = date();  
const y = isJuly(x) | x.isJuly();

const value = y.eval();

isAugust

isAugust(xdate) ➜ yboolean
xdate.isAugust() ➜ yboolean

The isAugust operator allows to create a boolean expression which evals the true if x is in august

import {date, isAugust} from "@compute.ts/date"

const x = date();  
const y = isAugust(x)| x.isAugust();

const value = y.eval();

isSeptember

isSeptember(xdate) ➜ yboolean
xdate.isSeptember() ➜ yboolean

The isSeptember operator allows to create a boolean expression which evals the true if x is in september

import {date, isSeptember} from "@compute.ts/date"

const x = date();  
const y = isSeptember(x) | x.isSeptember();

const value = y.eval();

isOctober

isOctober(xdate) ➜ yboolean
xdate.isOctober() ➜ yboolean

The isOctober operator allows to create a boolean expression which evals the true if x is in october

import {date, isOctober} from "@compute.ts/date"

const x = date();  
const y = isOctober(x) | x.isOctober();

const value = y.eval();

isNovember

isNovember(xdate) ➜ yboolean
xdate.isNovember() ➜ yboolean

The isNovember operator allows to create a boolean expression which evals the true if x is in november

import {date, isNovember} from "@compute.ts/date"

const x = date();  
const y = isNovember(x) | x.isNovember();

const value = y.eval();

isDecember

isDecember(xdate) ➜ yboolean
xdate.isDecember() ➜ yboolean

The isDecember operator allows to create a boolean expression which evals the true if x is in december

import {date, isDecember} from "@compute.ts/date"

const x = date();  
const y = isDecember(x) | x.isDecember();

const value = y.eval();

isBefore

isBefore(xdate, ydate) ➜ zboolean
xdate.isBefore(ydate) ➜ zboolean

The isBefore operator allows to create a boolean expression which evals the true if x is before y

import {date, isBefore} from "@compute.ts/date"

const x = date();  
const y = date();  
const z = isBefore(x, y) | x.isBefore(y);

const value = z.eval();

isBeforeOrSame

isBeforeOrSame(xdate, ydate) ➜ zboolean
xdate.isBeforeOrSame(ydate) ➜ zboolean

The isBeforeOrSame operator allows to create a boolean expression which evals the true if x is before or same as y

import {date, isBeforeOrSame} from "@compute.ts/date"

const x = date();  
const y = date();  
const z = isBeforeOrSame(x, y) | x.isBeforeOrSame(y);

const value = z.eval();

isAfter

isAfter(xdate, ydate) ➜ zboolean
xdate.isAfter(ydate) ➜ zboolean

The isAfter operator allows to create a boolean expression which evals the true if x is after y

import {date, isAfter} from "@compute.ts/date"

const x = date();  
const y = date();  
const z = isAfter(x, y) | x.isAfter(y);

const value = z.eval();

isAfterOrSame

isAfterOrSame(xdate, ydate) ➜ zboolean
xdate.isAfterOrSame(ydate) ➜ zboolean

The isAfterOrSame operator allows to create a boolean expression which evals the true if x is after or same as y

import {date, isAfterOrSame} from "@compute.ts/date"

const x = date();  
const y = date();  
const z = isAfterOrSame(x, y) | x.isAfterOrSame(y);

const value = z.eval();

About the author

I am a software developer with 4 years of project specializing in the development of web solutions. Digital Nomad, I work while traveling. After 3 years into the french industry, I've started to work as a freelance software architect or fullstack developer.

Based on state-of-the-art web technologies, I offer you to architect & develop the best version of your project. My experience in the web app development assure you to build a nice looking, performant and stable product.

Minimalist, I like to travel, to meet people, learn new things and handmade stuff. Scuba & sky diving licenced. I like also hamburgers, Kinder chocolate and crepes. Karate black belt.

https://berthellemy.com/


Package Sidebar

Install

npm i @compute.ts/date

Weekly Downloads

0

Version

2.0.3

License

MIT

Unpacked Size

61.8 kB

Total Files

16

Last publish

Collaborators

  • mberthellemy