Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace DayJS #2235

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/support/engineUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
readFile as _readFile
} from 'node:fs';
import { pathToFileURL } from 'node:url';
import dayjs from 'dayjs';
import intel from 'intel';
import { toArray } from '../support/util.js';
import { toArray, localTime } from '../support/util.js';
const log = intel.getLogger('browsertime');
const writeFile = promisify(_writeFile);
const readFile = promisify(_readFile);
Expand Down Expand Up @@ -104,5 +103,5 @@ export async function loadScript(script, options, throwError) {
return script;
}
export function timestamp() {
return dayjs().format();
return localTime();
}
4 changes: 2 additions & 2 deletions lib/support/har/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import merge from 'lodash.merge';
import pick from 'lodash.pick';
import isEmpty from 'lodash.isempty';
import get from 'lodash.get';
import dayjs from 'dayjs';
import { pathToFolder } from '../pathToFolder.js';
import { localTime } from '../util.js';
import intel from 'intel';
const log = intel.getLogger('browsertime');
const require = createRequire(import.meta.url);
Expand Down Expand Up @@ -288,7 +288,7 @@ export function getEmptyHAR(url, browser) {
},
pages: [
{
startedDateTime: dayjs().format(),
startedDateTime: localTime(),
id: 'failing_page',
title: url,
pageTimings: {},
Expand Down
5 changes: 3 additions & 2 deletions lib/support/storageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
} from 'node:fs';
import isEmpty from 'lodash.isempty';
import intel from 'intel';
import dayjs from 'dayjs';
import { localTime } from './util.js';

const gunzip = promisify(_gunzip);
const writeFile = promisify(_writeFile);
const readFile = promisify(_readFile);
Expand All @@ -23,7 +24,7 @@ const mkdir = promisify(_mkdir);
const log = intel.getLogger('browsertime');

const defaultDir = 'browsertime-results';
let timestamp = dayjs().format().replaceAll(':', '');
let timestamp = localTime().replaceAll(':', '');

function pathNameFromUrl(url) {
const parsedUrl = parse(url),
Expand Down
21 changes: 21 additions & 0 deletions lib/support/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,24 @@ export function adjustVisualProgressTimestamps(
}
return visualProgress;
}

export function localTime() {
const date = new Date();

const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');

const offset = -date.getTimezoneOffset();
const sign = offset >= 0 ? '+' : '-';
const offsetHours = String(Math.floor(Math.abs(offset) / 60)).padStart(
2,
'0'
);
const offsetMinutes = String(Math.abs(offset) % 60).padStart(2, '0');

return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${sign}${offsetHours}:${offsetMinutes}`;
}
11 changes: 0 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@sitespeed.io/tracium": "0.3.3",
"chrome-har": "1.0.1",
"chrome-remote-interface": "0.33.2",
"dayjs": "1.11.13",
"execa": "9.5.2",
"fast-stats": "0.0.7",
"ff-test-bidi-har-export": "0.0.17",
Expand Down
Loading