Changeset View
Changeset View
Standalone View
Standalone View
cypress/utils/index.js
/** | /** | ||||
* Copyright (C) 2019 The Software Heritage developers | * Copyright (C) 2019 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import axios from 'axios'; | import axios from 'axios'; | ||||
export async function httpGetJson(url) { | export async function httpGetJson(url) { | ||||
const response = await axios.get(url); | const response = await axios.get(url); | ||||
return response.data; | return response.data; | ||||
} | } | ||||
/** | |||||
* Converts string with Time information | |||||
* to an object with Time information | |||||
*/ | |||||
export function getTime(text) { | |||||
const date = new Date(text); | |||||
function pad(n) { | |||||
return n < 10 ? '0' + n : n; | |||||
} | |||||
const time = { | |||||
date: date.getUTCDate(), | |||||
month: date.getUTCMonth(), | |||||
monthName: date.toLocaleString('en', { month: 'long' }), | |||||
year: date.getUTCFullYear(), | |||||
hours: pad(date.getUTCHours()), | |||||
minutes: pad(date.getUTCMinutes()) | |||||
}; | |||||
return time; | |||||
} |