
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
I wrote it '-5m' ago.
Datelative is a JavaScript library that converts relative date strings to actual date objects. It's a handy tool for dealing with date and time manipulations in your JavaScript applications.
You can install Datelative using npm:
npm install datelative
Or using yarn:
yarn add datelative
First, import the relativeToDate
function from the library:
import { relativeToDate } from 'datelative';
Then, you can use it to convert relative date strings to date objects. Here are some examples:
const reference = new Date(); // Optional reference date, defaults to the current date and time
// Add 2 days to the reference date
const date1 = relativeToDate('+2 days', reference);
// Subtract 2 days from the reference date
const date2 = relativeToDate('-2 days', reference);
// Add 2 weeks to the reference date
const date3 = relativeToDate('+2 weeks', reference);
// Subtract 2 weeks from the reference date
const date4 = relativeToDate('-2 weeks', reference);
// ... and so on for months, years, quarters, milliseconds, seconds, minutes, and hours
Sure, here's the content for the README file with "+2" in front of each unit:
The + sign is optional and can be omitted.
The space between the number and the unit is also optional.
For example +2 ms
is the same as 2ms
.
see index.js for all available units.
This library includes a comprehensive set of tests to ensure its functionality. You can run these tests using npm:
npm test
Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the terms of the MIT license.
FAQs
A library that converts relative string text to JavaScript dates
The npm package datelative receives a total of 60 weekly downloads. As such, datelative popularity was classified as not popular.
We found that datelative demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.