Skip to content

Commit

Permalink
fix: reverts the perf change removing date-fns as it resulted in negl…
Browse files Browse the repository at this point in the history
…igible savings
  • Loading branch information
Andrew Stacy committed Sep 12, 2024
1 parent 771c5eb commit 6cbab4f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
"@vuepress/theme-default": "^2.0.0-rc.11",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"date-fns": "^3.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"happy-dom": "^15.7.3",
Expand All @@ -87,6 +86,7 @@
"**/*.{js,ts}": "eslint --fix"
},
"dependencies": {
"date-fns": "^3.6.0",
"chalk": "^5.3.0",
"vuepress-plugin-search-pro": "^2.0.0-rc.52"
},
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { formatISO } from '../functions';
import { formatISO } from 'date-fns/formatISO';
import { LevelConfiguration, ModifierData } from '../_types';
import { Configuration } from '../configuration';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/json/json.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Formatter from '../formatter';
import { ModifierData } from '../../_types';
import { formatISO } from '../../functions';
import { formatISO } from 'date-fns/formatISO';
import { JsonLog, JsonLogOptionalFields, JsonLogRequiredFields } from './types';
import { hasRequiredFields } from './type-guards';
import { setup } from '../../functions';
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/standard/standard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Formatter from '../formatter';
import { ModifierData } from '../../_types';
import { formatISO } from '../../functions';
import { formatISO } from 'date-fns/formatISO';
import { isNumber, isObject, isString } from '../../functions';

/**
Expand Down
26 changes: 0 additions & 26 deletions src/functions/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,3 @@ export function getActiveLevel(cfg: Configuration): number {
export function leadingZero(num: number): string {
return (num < 10 ? '0' : '') + `${num}`;
}

/**
* Returns an ISO-8601 formatted string from the provided date.
*/
export function formatISO(date: Date) {
const tzo = -date.getTimezoneOffset();
const dif = tzo >= 0 ? '+' : '-';

return (
`${date.getFullYear()}` +
'-' +
leadingZero(date.getMonth() + 1) +
'-' +
leadingZero(date.getDate()) +
'T' +
leadingZero(date.getHours()) +
':' +
leadingZero(date.getMinutes()) +
':' +
leadingZero(date.getSeconds()) +
dif +
leadingZero(Math.floor(Math.abs(tzo) / 60)) +
':' +
leadingZero(Math.abs(tzo) % 60)
);
}

0 comments on commit 6cbab4f

Please sign in to comment.