Modules@robinpath/date

@robinpath/date

0.1.0Public

Parse, format, manipulate, and compare dates and times

@robinpath/date

Parse, format, manipulate, and compare dates and times

Category Functions Auth License

Why use this module?

The date module lets you:

  • Parse a date string and return its ISO representation
  • Format a date using a pattern string
  • Add a duration to a date
  • Subtract a duration from a date
  • Calculate the difference between two dates in a given unit

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/date

Quick Start

No credentials needed — start using it right away:

date.format $date "YYYY-MM-DD"

Available Functions

FunctionDescription
date.parseParse a date string and return its ISO representation
date.formatFormat a date using a pattern string
date.addAdd a duration to a date
date.subtractSubtract a duration from a date
date.diffCalculate the difference between two dates in a given unit
date.startOfGet the start of a time period for a date
date.endOfGet the end of a time period for a date
date.isAfterCheck if the first date is after the second date
date.isBeforeCheck if the first date is before the second date
date.isBetweenCheck if a date falls between two other dates (exclusive)
date.toISOConvert a date to an ISO 8601 string
date.toUnixConvert a date to a Unix timestamp (seconds since epoch)
date.fromUnixConvert a Unix timestamp (seconds) to an ISO date string
date.dayOfWeekGet the day of the week for a date (0 = Sunday, 6 = Saturday)
date.daysInMonthGet the number of days in the month of a given date

Examples

Format a date using a pattern string

date.format $date "YYYY-MM-DD"

Add a duration to a date

date.add $date 5 "days"

Subtract a duration from a date

date.subtract $date 3 "months"

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/date";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  date.format $date "YYYY-MM-DD"
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/date
Version0.1.0
LicenseMIT
Unpacked Size7.5 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities