New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

time-date-tools

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-date-tools - npm Package Compare versions

Comparing version 0.0.22 to 0.0.24

15

dist/utils/class/DateFormat.js

@@ -45,3 +45,2 @@ var __defProp = Object.defineProperty;

const obj = {
date,
S: ("000" + date.getMilliseconds()).slice(-3),

@@ -80,3 +79,3 @@ SS: ("00" + date.getMilliseconds()).slice(-2),

let text = "";
const arr = ["YYYY", "YY", "HH", "H", "hh", "h", "mm", "m", "ss", "s", "SSS", "SS", "S", "DDD", "DD", "D", "dddd", "ddd", "dd", "MMMM", "MMM", "MM", "M", "R", "AA", "A", "aa", "a"];
const arr = ["YYYY", "YY", "HH", "H", "hh", "h", "mm", "m", "ss", "s", "SSS", "SS", "S", "DDD", "DD", "D", "MMMM", "MMM", "MM", "M", "R", "AA", "A", "aa", "a", "dddd", "ddd", "dd"];
for (let i in splitFormat) {

@@ -86,10 +85,12 @@ let key = splitFormat[i];

for (let j of arr) {
const reg2 = new RegExp("(?<!])" + j, "g");
key = key.replace(reg2, "]" + typeof obj[j] == "string" ? obj[j].split("").join("]") : obj[j]);
const reg2 = new RegExp(j + "(?!])", "g");
key = key.replace(reg2, typeof obj[j] == "string" ? obj[j].split("").join("]") : obj[j]);
}
text += key;
}
const separator = matchFormat[i];
if (separator)
text += separator;
if (matchFormat) {
const separator = matchFormat[i];
if (separator)
text += separator;
}
}

@@ -96,0 +97,0 @@ return text.replace(/\[|]/g, "");

@@ -28,3 +28,3 @@ var __defProp = Object.defineProperty;

constructor(options) {
this.#format = options?.format || "Y YYYY, M MMMM, W WWWW, D dddd, h HH, m MM, s SS, sss SSSS";
this.#format = options?.format || "Y YYYY, M MMMM, W WWWW, D DDDD, h HH, m MM, s SS, sss SSSS";
this.lang = options?.lang || "en";

@@ -105,3 +105,3 @@ this.precision = options?.precision != false | 0;

const index = (typeof obj[match[0] || ""] == "string" ? unities : values).indexOf(match[0]);
if (write || obj[match[0]] && !!obj[values[index]]) {
if (write || (obj[match[0]] && !!obj[values[index]] || !!obj[unities[index]])) {
arrayTime.push(match[0]);

@@ -108,0 +108,0 @@ if (arrayTime.length != 1)

{
"name": "time-date-tools",
"version": "0.0.22",
"version": "0.0.24",
"description": "",

@@ -21,3 +21,4 @@ "main": "./dist/index.js",

"format",
"discord.js"
"discord.js",
"discord"
],

@@ -30,3 +31,3 @@ "scripts": {

"type": "git",
"url": "https://github.com/joanc-04/date-time-tools.git"
"url": "https://github.com/joanc-04/time-date-tools.git"
},

@@ -37,7 +38,5 @@ "author": "Joan",

"@types/node": "^17.0.38",
"esbuild": "^0.14.42"
"esbuild": "^0.14.42",
"typescript": "^4.7.4"
},
"dependencies": {
"typescript": "^4.7.2"
},
"engines": {

@@ -44,0 +43,0 @@ "node": ">=16.0.0",

# About
`time-date-tools` is a powerful Node.js module that allows you to **easily manage time** and **date**. You can configure a lot of features to not have date and time issues anymore.
<br>
If you have any question, you can join our community on [**Discord**](https://discord.gg/bUnFAccHmJ).
### Features
- [Installation](https://github.com/joanc-04/time-date-tools/#installation)
- [Importation](https://github.com/joanc-04/time-date-tools/#importation:)
- [Importation](https://github.com/joanc-04/time-date-tools/#importation)
- [Time](https://github.com/joanc-04/time-date-tools/#time)

@@ -49,4 +51,35 @@ * [Format](https://github.com/joanc-04/time-date-tools/#format-time) : Convert a time in milliseconds to a time in string.

\*Format: By default, the null unities aren't displayed. If you want to display them, you can surround some parts of the format by `[` and `]`.
<br>
Available token for the time format:
|Token|Meaning|Examples of output|
|:-:|:-:|:-:|
|YYYY|Year unity|years, year|
|yyyy|Year unity (short)|y|
|Y|Year value|1|
|MMMM|Month unity|months, month|
|mmmm|Month unity (short)|mo|
|M|Month value|2|
|WWWW|Week unity|weeks, week|
|wwww|Week unity (short)|w|
|W|Week value|3|
|DDDD|Day unity|days, day|
|dddd|Day unity (short)|d|
|D|Day value|4|
|HH|Hour unity|hours, hour|
|hh|Hour unity (short)|h|
|h|Hour value|5|
|MM|Minute unity|minutes, minute|
|mm|Minute unity (short)|m|
|m|Minute value|6|
|SS|Second unity|seconds, second|
|ss|Second unity (short)|s|
|sss|Second value|7|
|SSSS|Millisecond unity|milliseconds, millisecond|
|ssss|Millisecond unity (short)|ms|
|sss|Millisecond value|8|
<br>
<br>

@@ -58,3 +91,3 @@ > #### Function *format()*:

```ts
const TimeSettingsFormat = new TimeSettings({ lang: "en", format: "Y YYYY, M MMMM, W WWWW, D dddd, h HH, m MM, s SS, sss SSSS" });
const TimeSettingsFormat = new TimeSettings({ lang: "en", format: "Y YYYY, M MMMM, W WWWW, D DDDD, h HH, m MM, s SS, sss SSSS" });
TimeSettingsFormat.format(timeInMilliseconds);

@@ -112,3 +145,3 @@ ```

const TimeSettingsParse = new TimeSettings();
TimeSettingsParse.parse(timeInMilliseconds);
TimeSettingsParse.parse(timeInString);
```

@@ -119,3 +152,3 @@ Available arguments in the `parse()` function:

|:-:|:-:|:-:|:-:|:-:|
|timeInMilliseconds|[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)|❌||Time in milliseconds to convert into a string.|
|timeInString|[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)|❌||Time in string to convert into milliseconds.|

@@ -146,3 +179,3 @@ <br>

```ts
new TimeSettings(options);
new DateSettings(options);
```

@@ -156,5 +189,40 @@ Available options in the configuration for the `format()` function:

*Format: If you want to dodge some words in the format string, you can surround them with `[` and `]`. It can be useful if you want to format a date, you can refer to the examples.
*Format: If you want to dodge some words in the format string, you can surround them with `[` and `]`. It can be useful if you want to format a date, you can refer to the examples.
<br>
Available token for the date format:
|Token|Meaning|Examples of output|
|:-:|:-:|:-:|
|YYYY|Four-digit year|1970, 2022|
|YY|Two-digit year|70, 22|
|MMMM|Month name (long)|January, December|
|MMM|Month name (short)|Jan, Dec|
|MM|Two-digit month|01, 12|
|M|One-digit month|1, 12|
|dddd|Day of week (long)|monday, sunday|
|ddd|Day of week (short - three-digit)|mon, sun|
|dd|Day of week (short - two-digit)|mo, su|
|DDD|Ordinal notation of date|1st, 2nd, 3rd, 4th|
|DD|Two-digit date|01, 31|
|D|One-digit date|1, 31|
|HH|Two-digit 24-hour|01, 23|
|H|One-digit 24-hour|1, 23|
|hh|Two-digit 12-hour|01, 11|
|h|One-digit 12 hour|1, 11|
|mm|Two-digit minute|01, 59|
|m|One-digit minute|1, 59|
|ss|Two-digit second|01, 59|
|s|One-digit second|1, 59|
|SSS|Three-digit millisecond|001, 999|
|SS|Two-digit millisecond|01, 99|
|S|One-digit millisecond|1, 9|
|R|Roman year|MMXXII|
|AA|Meridiem (uppercase with ellipsis)|A.M., P.M.|
|A|Meridiem (uppercase)|AM, PM|
|aa|Meridiem (lowercase with ellipsis)|a.m., p.m.|
|a|Meridiem|am, pm|
<br>
<br>

@@ -161,0 +229,0 @@ > #### Function *format()*:

@@ -7,3 +7,3 @@ export interface OptionsDateSettings {

export interface OptionsTimeSettings {
format?: string | "Y YYYY, M MMMM, W WWWW, D dddd, h HH, m MM, s SS, sss SSSS";
format?: string | "Y YYYY, M MMMM, W WWWW, D DDDD, h HH, m MM, s SS, sss SSSS";
lang?: string | "en";

@@ -10,0 +10,0 @@ precision?: boolean | "true";

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc