mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1154717 - Fix toLocalTimeISOString(). r=yoric
This commit is contained in:
parent
d922320c54
commit
df9db8b754
@ -249,7 +249,8 @@ function toLocalTimeISOString(date) {
|
||||
}
|
||||
|
||||
let sign = (n) => n >= 0 ? "+" : "-";
|
||||
let tzOffset = date.getTimezoneOffset();
|
||||
// getTimezoneOffset counter-intuitively returns -60 for UTC+1.
|
||||
let tzOffset = - date.getTimezoneOffset();
|
||||
|
||||
// YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
|
||||
return padNumber(date.getFullYear(), 4)
|
||||
@ -259,8 +260,8 @@ function toLocalTimeISOString(date) {
|
||||
+ ":" + padNumber(date.getMinutes(), 2)
|
||||
+ ":" + padNumber(date.getSeconds(), 2)
|
||||
+ "." + date.getMilliseconds()
|
||||
+ sign(tzOffset) + Math.abs(Math.floor(tzOffset / 60))
|
||||
+ ":" + Math.abs(tzOffset % 60);
|
||||
+ sign(tzOffset) + padNumber(Math.floor(Math.abs(tzOffset / 60)), 2)
|
||||
+ ":" + padNumber(Math.abs(tzOffset % 60), 2);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,15 +212,23 @@ function checkPayloadInfo(data) {
|
||||
const ALLOWED_REASONS = [
|
||||
"environment-change", "shutdown", "daily", "saved-session", "test-ping"
|
||||
];
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
let numberCheck = arg => { return (typeof arg == "number"); };
|
||||
let positiveNumberCheck = arg => { return numberCheck(arg) && (arg >= 0); };
|
||||
let stringCheck = arg => { return (typeof arg == "string") && (arg != ""); };
|
||||
let isoDateCheck = arg => { return stringCheck(arg) && !Number.isNaN(Date.parse(arg)); }
|
||||
let revisionCheck = arg => {
|
||||
return (Services.appinfo.isOfficial) ? stringCheck(arg) : (typeof arg == "string");
|
||||
};
|
||||
let uuidCheck = arg => uuidRegex.test(arg);
|
||||
let uuidCheck = arg => {
|
||||
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
||||
return uuidRegex.test(arg);
|
||||
};
|
||||
let isoDateCheck = arg => {
|
||||
// We expect use of this version of the ISO format:
|
||||
// 2015-04-12T18:51:19.1+00:00
|
||||
const isoDateRegEx = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+[+-]\d{2}:\d{2}$/;
|
||||
return stringCheck(arg) && !Number.isNaN(Date.parse(arg)) &&
|
||||
isoDateRegEx.test(arg);
|
||||
};
|
||||
|
||||
const EXPECTED_INFO_FIELDS_TYPES = {
|
||||
reason: stringCheck,
|
||||
|
Loading…
Reference in New Issue
Block a user