Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
date-duration
Advanced tools
Manipulate Date objects with ISO 8601-formatted durations.
$ npm install date-duration
import Duration from 'date-duration';
let duration = Duration('PT1H');
// or
let duration = Duration({P: {T: {H: 1}}});
Note: keep in mind that working with time-only durations (hours, minutes, seconds) is generally a better idea.
A duration of PT36H
is not the same as P1DT12H
. The former will add/subtract exactly 36 hours while the latter will add 12 hours + whatever 1 day means. e.g. if jumping across DST (Daylight saving time) and the difference is 1 hour, this totals to plus/minus 35 hours or 37 hours.
This is generally what you want as long as you take into account this happens within the context of the timezone of your environment. This can become tricky when used in browsers (where you don't have control over this).
Pass a string in ISO 8601 duration format to create a duration.
Add the duration to a Date object and returns the new date. Objects with a .toDate()
(like Moment.js) method are converted to a regular Date object.
Subtract the duration from a Date object and returns the new date. Objects with a .toDate()
method are converted to a regular Date object.
Add durations together returning a new duration which is the sum of both.
Multiply individual parts of duration returning a new duration as the result.
Convert a duration to a string in ISO 8601 format.
FAQs
Manipulate Date objects with ISO 8601-formatted durations
The npm package date-duration receives a total of 187 weekly downloads. As such, date-duration popularity was classified as not popular.
We found that date-duration 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.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.