string-datetime
v0.1.2
Published
Convert well-formed strings like 'in 1 days' to Luxon datetimes with first-class typescript support
Downloads
2
Readme
string-datetime
Developer-friendly utilities for calculating Luxon datetimes from strings.
Usage:
import { DatetimeString, parseStringToDateTime } from "string-datetime";
// return Luxon DateTime object one day from now
const datetime = parseStringToDateTime("in 1 days");
// will not compile: string-datetime uses string templates for compile-time datetime string checking
const errorDatetime = parseStringToDateTime("in 1 daos");
Supported datetime strings:
in <number> seconds
in <number> minutes
in <number> hours
in <number> days
in <number> weeks
in <number> months
by <number> seconds
by <number> minutes
by <number> hours
by <number> days
by <number> weeks
by <number> months
<number> seconds
<number> minutes
<number> hours
<number> days
<number> weeks
<number> months
next second
next minute
next hour
next day
next week
next weekday
next weekend
next month
These will all return future datetimes at the moment