Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@invilite/date
Advanced tools
Readme
Extends native Date object by adding new methods.
This is a Node.js module available through the npm registry.
Using npm:
$ npm install @invilite/date
Using bower:
$ bower install @invilite/date
Using yarn:
$ yarn add @invilite/date
import "@invilite/date";
const date = new Date();
// Outputs: 2022-04-08 14:30:00.0
console.log(date.format("YY-MM-D HH:mm:ss.S"));
Return the formatted date string in the given format, optionally converts to different timezone.
format(format: string, locales?: string | string[], timezoneName?: string): string;
const date = new Date();
const formattedDate = date.format("YY-MM-D HH:mm:ss.S");
const date = new Date("2022-04-18 15:30:00 +01:00");
// Convert time to Tokyo timezone
const formattedTime = date.format("YY-MM-D HH:mm:ss.S", "en-US", "Asia/Tokyo");
Pattern | Description | Example |
---|---|---|
Y | A two digit representation of a year | 22 |
YY | A full numeric representation of a year | 2022 |
M | Numeric representation of a month, without leading zeros | 3 |
MM | Numeric representation of a month, with leading zeros | 03 |
B | Full month name | January |
b | Short month name | Jan |
D | Day of the month without leading zeros | 9 |
DD | Day of the month, 2 digits with leading zeros | 09 |
w | Numeric representation of the day of the week | 05 |
W | Week of the year | 28 |
H | 24-hour format of an hour without leading zeros | 17 |
HH | 24-hour format of an hour with leading zeros | 17 |
h | 12-hour format of an hour without leading zeros | 9 |
hh | 12-hour format of an hour with leading zeros | 09 |
m | Minutes without leading zeros | 5 |
mm | Minutes with leading zeros | 05 |
s | Seconds without leading zeros | 0 |
ss | Seconds with leading zeros | 00 |
S | Milliseconds without leading zeros | 34 |
SS | Milliseconds with leading zeros | 034 |
a | Lowercase Ante meridiem and Post meridiem | am |
A | Uppercase Ante meridiem and Post meridiem | AM |
z | Timezone offset in minutes | -120 |
Z | Timezone offset in standard format | +02:00 |
X | Unit timestamp (in seconds) | 1659306131 |
Get the seconds timestamp of the given date.
toUnixTimestamp(): number;
const date = new Date();
const timestamp = date.toUnixTimestamp();
Add the specified number of seconds to the given date. Returns current object with the seconds added.
addSeconds(seconds: number): Date;
const date = new Date();
date.addSeconds(600);
Get number of seconds, that represents time difference between two dates.
diffFrom(date: Date | string = new Date()): number;
const date = new Date("2022-04-18 15:50:40");
const futureDate = new Date("2022-04-18 14:30:00");
console.log(date.diffFrom(futureDate));
// Outputs: 4840
Get formatted string (in English), that represents time difference between two dates.
textDiffFrom(date: Date): string;
const date = new Date("2022-04-18 15:50:40");
const futureDate = new Date("2022-04-18 14:30:00");
console.log(date.textDiffFrom(futureDate));
// Outputs: '1 hour, 20 minutes, 40 seconds'
TBD
Library is licensed under a GNU General Public License v3.0
FAQs
Extends native JavaScript Date object by adding new methods.
The npm package @invilite/date receives a total of 0 weekly downloads. As such, @invilite/date popularity was classified as not popular.
We found that @invilite/date 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.