2019-08-16 12:05:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////
|
2019-08-17 12:32:35 +02:00
|
|
|
/* Fonctions Principales */
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
// Requête à l'API openweathermap.org
|
2019-08-16 12:05:56 +02:00
|
|
|
function weatherRequest(url,toDo) {
|
|
|
|
$.ajax({
|
|
|
|
url : url,
|
|
|
|
dataType : "json",
|
|
|
|
success: function (json) {
|
|
|
|
let city = json.name;
|
|
|
|
let showDateTimeValue = timeZone(json);
|
|
|
|
switch (toDo) {
|
|
|
|
case 'time':
|
|
|
|
$('.results').html("La date et l'heure de " + city + " : " + showDateTimeValue);
|
2019-08-18 20:06:06 +02:00
|
|
|
$("#cityName, #submitWeatherRequest").click(function() {
|
2019-08-19 18:42:54 +02:00
|
|
|
document.location.replace("../../views/function-views/weatherRequest.php");
|
2019-08-18 20:06:06 +02:00
|
|
|
});
|
2019-08-16 12:05:56 +02:00
|
|
|
break;
|
|
|
|
case 'weather':
|
|
|
|
if(city === 'Moscou')
|
|
|
|
{
|
|
|
|
$('.results').html(`🌎 Position : <a href='https://www.google.com/maps/place/${city}/' class="yellow-color" target="_blank">${city}, RU</a><br>⏰ Date et heure : ${showDateTimeValue}<br>☁️ Météo : ${capitalize(json.weather[0].description)}<br> 🌡️ Température : ${json.main.temp} °C<br> 💧 Humidité : ${json.main.humidity}% <br> <img src="https://openweathermap.org/img/wn/${json.weather[0].icon}@2x.png"/>`);
|
2019-08-18 20:06:06 +02:00
|
|
|
$("#cityName, #submitWeatherRequest").click(function() {
|
2019-08-19 18:42:54 +02:00
|
|
|
document.location.replace("../../views/function-views/weatherRequest.php");
|
2019-08-18 20:06:06 +02:00
|
|
|
});
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$('.results').html(`🌎 Position : <a href='https://www.google.com/maps/place/${city}/' class="yellow-color" target="_blank">${city}, ${json.sys.country}</a><br>⏰ Date et heure : ${showDateTimeValue}<br>☁️ Météo : ${capitalize(json.weather[0].description)}<br> 🌡️ Température : ${json.main.temp} °C<br> 💧 Humidité : ${json.main.humidity}% <br> <img src="https://openweathermap.org/img/wn/${json.weather[0].icon}@2x.png"/>`);
|
2019-08-18 20:06:06 +02:00
|
|
|
$("#cityName, #submitWeatherRequest").click(function() {
|
2019-08-19 18:42:54 +02:00
|
|
|
document.location.replace("../../views/function-views/weatherRequest.php");
|
2019-08-18 20:06:06 +02:00
|
|
|
});
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
},
|
|
|
|
statusCode: {
|
|
|
|
404: function() {
|
2019-09-13 21:56:36 +02:00
|
|
|
document.location.replace("../error404Weather");
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Génère un nombre aléatoire entre un minimum inclus et un maximum inclus
|
2019-08-18 20:06:06 +02:00
|
|
|
function randomNumber(min, max) {
|
|
|
|
min = Math.ceil(min);
|
|
|
|
max = Math.floor(max);
|
2019-08-16 12:05:56 +02:00
|
|
|
|
|
|
|
if (!isNaN(min) && !isNaN(max) && min < max)
|
|
|
|
{
|
2019-09-13 14:39:29 +02:00
|
|
|
return Math.floor(Math.random() * (max - min +1)) + min;
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
2019-09-13 14:39:29 +02:00
|
|
|
else {
|
|
|
|
return null;
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calcule l'âge de quelqu'un selon la date de naissance
|
2019-08-18 20:06:06 +02:00
|
|
|
function calculateAge(birthDateEntered) {
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
// Les variables de la fonction
|
|
|
|
let birthDateDay = parseInt(birthDateEntered[0] + birthDateEntered[1]);
|
|
|
|
let birthDateMonth = parseInt((birthDateEntered[3] + birthDateEntered[4]) - 1);
|
|
|
|
let birthDateYear = parseInt(birthDateEntered[6] + birthDateEntered[7] + birthDateEntered[8] + birthDateEntered[9]);
|
|
|
|
dateTimeUTC('0');
|
|
|
|
day = parseInt(day)
|
|
|
|
month = parseInt(month - 1);
|
|
|
|
year = parseInt(year);
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
let dateNow = moment([year, month, day]);
|
|
|
|
let birthDate = moment([birthDateYear, birthDateMonth, birthDateDay]);
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
// Calcule l'âge - Moment.js
|
|
|
|
let ageYears = dateNow.diff(birthDate, 'year');
|
|
|
|
birthDate.add(ageYears, 'years');
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
let ageMonths = dateNow.diff(birthDate, 'months');
|
|
|
|
birthDate.add(ageMonths, 'months');
|
|
|
|
|
|
|
|
let ageDays = dateNow.diff(birthDate, 'days');
|
|
|
|
|
|
|
|
// Vérifie si la valeur entrée correspond à une date de naissance valide
|
|
|
|
if(birthDate._isValid === true)
|
|
|
|
{
|
|
|
|
// Si c'est ton anniversaire aujourd'hui
|
|
|
|
if(birthDateDay === parseInt(day) && birthDateMonth === parseInt(month))
|
|
|
|
{
|
|
|
|
return 'Vous avez ' + ageYears + ' ans. Joyeux Anniversaire! 🥳';
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-18 20:06:06 +02:00
|
|
|
return 'Vous avez ' + ageYears + ' ans, ' + ageMonths + ' mois et ' + ageDays + ' jour(s).';
|
2019-08-16 12:05:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return messageError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 17:38:30 +02:00
|
|
|
// Convertis des °C en °F et l'inverse aussi
|
2019-08-16 12:05:56 +02:00
|
|
|
function convertTemperature(degree, unit) {
|
|
|
|
if (!isNaN(degree) && unit === "°C")
|
|
|
|
{
|
|
|
|
const temperatureValue = ((degree * 9/5) + 32) + " °F";
|
|
|
|
return temperatureValue;
|
|
|
|
}
|
|
|
|
else if (!isNaN(degree) && unit === "°F")
|
|
|
|
{
|
|
|
|
const temperatureValue = (degree - 32) * 5/9 + " °C";
|
|
|
|
return temperatureValue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return messageError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-14 17:38:30 +02:00
|
|
|
// Convertis la longueur (distance) avec les unités allant de picomètre au Téramètre
|
2019-08-16 12:05:56 +02:00
|
|
|
function convertDistance (firstValue, unitFirstValue, unitFinalValue) {
|
|
|
|
|
|
|
|
let reference = ["pm",null,null,"nm",null,null,"µm",null,null,"mm","cm","dm","m","dam","hm","km",null,null,"Mm",null,null,"Gm",null,null,"Tm"];
|
|
|
|
let index1 = reference.indexOf(unitFirstValue);
|
|
|
|
let index2 = reference.indexOf(unitFinalValue);
|
|
|
|
|
|
|
|
// Condition qui vérifie si les valeurs entrées sont justes
|
|
|
|
if (!isNaN(firstValue) && typeof unitFirstValue === 'string' && typeof unitFinalValue === 'string' && (index1.toString() && index2.toString()) != '-1')
|
|
|
|
{
|
|
|
|
// Conversion des longueurs :
|
|
|
|
let difference = index1 - index2;
|
|
|
|
let result = firstValue*Math.pow(10,difference);
|
2019-09-15 09:45:20 +02:00
|
|
|
let response = 'Conversion de longueur : ' + formatNumberResult(firstValue).toString() + ' ' + unitFirstValue + ' = ' + formatNumberResult(result) + ' ' + unitFinalValue;
|
2019-08-16 12:05:56 +02:00
|
|
|
return response;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return messageError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-29 14:53:15 +02:00
|
|
|
// Affiche uniquement les prénoms (qui sont dans la liste) qui commence par la lettre souhaitée
|
|
|
|
function filterStudents(filteredLetter, students)
|
|
|
|
{
|
|
|
|
let filteredStudents = [];
|
|
|
|
for(let i = 0; i < students.length; i++)
|
|
|
|
{
|
2019-08-30 00:00:29 +02:00
|
|
|
let studentBoucle = capitalize(students[i]);
|
2019-08-29 14:53:15 +02:00
|
|
|
if (studentBoucle[0] === filteredLetter) {
|
|
|
|
filteredStudents.push(studentBoucle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filteredStudents.length === 1)
|
|
|
|
{
|
|
|
|
return ("Prénom qui commence par " + filteredLetter + " : " + filteredStudents + '.');
|
|
|
|
}
|
|
|
|
else if (filteredStudents.length >= 2)
|
|
|
|
{
|
|
|
|
// Affiche la liste des prénoms...
|
|
|
|
let last = filteredStudents[filteredStudents.length - 1]; // Accéde au dernier élément du tableau
|
|
|
|
let totalfilteredLetterStudents = filteredStudents.length;
|
|
|
|
filteredStudents.pop(); // Supprime le dernier élément du tableau
|
|
|
|
// filteredStudents.join(', ') permet de rajouter un espace entre chaque élément du tableau
|
|
|
|
return ("Prénoms qui commence par " + filteredLetter + " (" + totalfilteredLetterStudents + ") : " + filteredStudents.join(', ') + ' et ' + last + '.');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return ("Il n'y a pas de prénom commencant par " + filteredLetter + ".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-13 21:56:36 +02:00
|
|
|
// Génère aléatoirement une citation ou un proverbe
|
2019-09-13 14:39:29 +02:00
|
|
|
function getRandomQuote() {
|
|
|
|
let randomNbr = randomNumber(0, (quotes.length - 1));
|
|
|
|
let randomQuotes = quotes[randomNbr];
|
|
|
|
return '" ' + randomQuotes["quote"] + ' " <br> <br> - ' + randomQuotes["source"];
|
|
|
|
}
|
|
|
|
|
2019-09-13 21:56:36 +02:00
|
|
|
// Convertis des euros (€) dans une autre devise
|
2019-09-13 23:00:41 +02:00
|
|
|
function convertCurrency(currency, euroValue) {
|
2019-09-13 21:56:36 +02:00
|
|
|
$.ajax({
|
2019-09-13 23:00:41 +02:00
|
|
|
url : 'https://api.exchangeratesapi.io/latest',
|
|
|
|
dataType : "json",
|
2019-09-13 21:56:36 +02:00
|
|
|
success: function (jsonFixer) {
|
|
|
|
switch(currency) {
|
|
|
|
case '£':
|
2019-09-13 22:44:37 +02:00
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.GBP) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case '$ Américain':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.USD) * euroValue)).toFixed(2) + ' ' + currency);
|
2019-09-13 21:56:36 +02:00
|
|
|
break;
|
2019-09-13 22:44:37 +02:00
|
|
|
case '$ Canadien':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.CAD) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case '$ Australien':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.AUD) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case '$ Mexicain':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.MXN) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case 'Fr':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.CHF) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case '₽':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.RUB) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case 'R$':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.BRL) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
|
|
|
case '¥':
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' € = ' + ((parseFloat(jsonFixer.rates.JPY) * euroValue)).toFixed(2) + ' ' + currency);
|
|
|
|
break;
|
2019-09-13 21:56:36 +02:00
|
|
|
default:
|
|
|
|
$('.results').html(formatNumberResult(euroValue) + ' €');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
statusCode: {
|
|
|
|
404: function() {
|
|
|
|
document.location.replace("../404.php");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-08-16 12:05:56 +02:00
|
|
|
|
2019-09-14 17:38:30 +02:00
|
|
|
// Convertis du texte (encodé en UTF-8) en binaire et l'inverse aussi (source : http://jsfiddle.net/47zwb41o)
|
|
|
|
// UTF-8 vers Binaire
|
|
|
|
function utf8ToBin(s) {
|
2019-09-15 22:21:02 +02:00
|
|
|
try {
|
|
|
|
s = unescape( encodeURIComponent(s));
|
|
|
|
var chr, i = 0, l = s.length, out = '';
|
|
|
|
for( ; i < l; i ++ ){
|
|
|
|
chr = s.charCodeAt( i ).toString(2);
|
|
|
|
while(chr.length % 8 != 0 ){ chr = '0' + chr; }
|
|
|
|
out += chr;
|
|
|
|
}
|
|
|
|
return out;
|
|
|
|
} catch (error) {
|
|
|
|
return s;
|
2019-09-14 17:38:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Binaire vers UTF-8
|
|
|
|
function binToUtf8(s){
|
2019-09-15 22:21:02 +02:00
|
|
|
try {
|
|
|
|
var i = 0, l = s.length, chr, out = '';
|
|
|
|
for( ; i < l; i += 8){
|
|
|
|
chr = parseInt( s.substr(i, 8 ), 2).toString(16);
|
|
|
|
out += '%' + ((chr.length % 2 == 0) ? chr : '0' + chr);
|
|
|
|
}
|
|
|
|
return decodeURIComponent(out);
|
|
|
|
} catch (error) {
|
|
|
|
return s;
|
2019-09-14 17:38:30 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-13 22:44:37 +02:00
|
|
|
|
2019-08-16 12:05:56 +02:00
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
/* Fonctions Annexes */
|
|
|
|
|
|
|
|
// Vérifie si une valeur est vide
|
|
|
|
function isEmptyValue(value) {
|
|
|
|
if (value === '' || value === null || value === undefined) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-17 12:32:35 +02:00
|
|
|
// Formate les nombres avec des espaces (ex : 76120 = 76 120)
|
2019-08-16 12:05:56 +02:00
|
|
|
function formatNumberResult(num) {
|
|
|
|
if (!isNaN(num))
|
|
|
|
{
|
|
|
|
if(num >= 1000)
|
|
|
|
{
|
|
|
|
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return messageError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-17 12:32:35 +02:00
|
|
|
// Convertit les puissances de 10 en nombre (ex: 1e+20 = 100 000 000 000 000 000 000), ne peut pas dépasser 1e+20 (21 ne fonctionne pas)
|
2019-08-16 12:05:56 +02:00
|
|
|
function convertPuissanceToNumber(num) {
|
|
|
|
if(!isNaN(num))
|
|
|
|
{
|
|
|
|
let number = formatNumberResult((num).toFixed(0));
|
|
|
|
return number;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return messageError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
// Majuscule à la 1ère lettre d'une string
|
2019-08-16 12:05:56 +02:00
|
|
|
function capitalize (s) {
|
|
|
|
if (typeof s !== 'string') return ''
|
|
|
|
return s.charAt(0).toUpperCase() + s.slice(1)
|
|
|
|
}
|
|
|
|
|
2019-08-17 12:32:35 +02:00
|
|
|
// Donne la date et l'heure selon l'UTC (Universal Time Coordinated)
|
2019-08-16 12:05:56 +02:00
|
|
|
function dateTimeUTC(utc) {
|
|
|
|
if(typeof utc === 'string' && utc.length >= 1 && utc[0] === '-' || '0' || '+' || !isNaN(parseFloat(utc[0])))
|
|
|
|
{
|
|
|
|
if (utc[0] === '0' && utc.length === 1)
|
|
|
|
{
|
|
|
|
let enteredOffset = 0;
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else if (utc[0] === '+' || !isNaN(parseFloat(utc[0])))
|
|
|
|
{
|
|
|
|
if (utc.length === 2 && utc[0] === '+')
|
|
|
|
{
|
|
|
|
// Entered offset
|
|
|
|
let enteredOffset = parseFloat(utc[1])*60;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() + enteredOffset);
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else if (utc.length === 3 && utc[0] === '+')
|
|
|
|
{
|
|
|
|
// Entered offset
|
|
|
|
let enteredOffset = parseFloat(utc[1] + utc[2])*60;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() + enteredOffset);
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else if (utc.length === 1 && !isNaN(parseFloat(utc[0])))
|
|
|
|
{
|
|
|
|
// Entered offset
|
|
|
|
let enteredOffset = parseFloat(utc[0])*60;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() + enteredOffset);
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else if (utc.length === 2 && !isNaN(parseFloat(utc[0])))
|
|
|
|
{
|
|
|
|
// Entered offset
|
|
|
|
let enteredOffset = parseFloat(utc[0] + utc[1])*60;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() + enteredOffset);
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let enteredOffset = 0;
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (utc[0] === '-')
|
|
|
|
{
|
|
|
|
if (utc.length === 2 && utc[0] === '-')
|
|
|
|
{
|
|
|
|
// Entered offset
|
|
|
|
let enteredOffset = - parseFloat(utc[1])*60;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() + enteredOffset);
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else if (utc.length === 3 && utc[0] === '-')
|
|
|
|
{
|
|
|
|
// Entered offset
|
|
|
|
let enteredOffset = - parseFloat(utc[1] + utc[2])*60;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() + enteredOffset);
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let enteredOffset = 0;
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let enteredOffset = 0;
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (utc === '' || !utc || utc === undefined)
|
|
|
|
{
|
|
|
|
utc = false;
|
|
|
|
let enteredOffset = 0;
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
let enteredOffset = 0;
|
|
|
|
return showDateTime(enteredOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-17 12:32:35 +02:00
|
|
|
// Affiche la date et l'heure (format : dd/mm/yyyy - 00:00:00)
|
2019-08-16 12:05:56 +02:00
|
|
|
function showDateTime(enteredOffset) {
|
|
|
|
year = timeNow.getFullYear();
|
|
|
|
month = ('0'+(timeNow.getMonth()+1)).slice(-2);
|
|
|
|
day = ('0'+timeNow.getDate()).slice(-2);
|
|
|
|
hour = ('0'+timeNow.getHours()).slice(-2);
|
|
|
|
minute = ('0'+timeNow.getMinutes()).slice(-2);
|
|
|
|
second = ('0'+timeNow.getSeconds()).slice(-2);
|
|
|
|
|
|
|
|
showDateTimeValue = day + "/" + month + "/" + year + " - " + hour + ":" + minute + ":" + second;
|
|
|
|
timeNow.setMinutes(timeNow.getMinutes() - enteredOffset)
|
|
|
|
|
|
|
|
return showDateTimeValue;
|
|
|
|
}
|
|
|
|
|
2019-08-17 12:32:35 +02:00
|
|
|
// Affiche l'heure en temps réel
|
|
|
|
function realDateTime(id)
|
|
|
|
{
|
2019-08-17 14:13:43 +02:00
|
|
|
realDateTimeNow = new Date;
|
|
|
|
year = realDateTimeNow.getFullYear();
|
|
|
|
month = ('0'+(realDateTimeNow.getMonth()+1)).slice(-2);
|
|
|
|
day = ('0'+realDateTimeNow.getDate()).slice(-2);
|
|
|
|
hour = ('0'+realDateTimeNow.getHours()).slice(-2);
|
|
|
|
minute = ('0'+realDateTimeNow.getMinutes()).slice(-2);
|
|
|
|
second = ('0'+realDateTimeNow.getSeconds()).slice(-2);
|
|
|
|
|
2019-08-17 12:32:35 +02:00
|
|
|
resultat = hour + ":" + minute + ":" + second;
|
|
|
|
|
|
|
|
document.getElementById(id).innerHTML = resultat;
|
|
|
|
setTimeout('realDateTime("'+id+'");','1000');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-08-18 20:06:06 +02:00
|
|
|
// Récupére le décalage en secondes à partir de l'heure UTC grâce à l'API
|
2019-08-16 12:05:56 +02:00
|
|
|
function timeZone(json) {
|
|
|
|
if(json.name === 'Moscou') // Il faut ajouter + 1h de décallage à Moscou
|
|
|
|
{
|
|
|
|
timeZoneValue = (json.timezone / 60 / 60) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
timeZoneValue = json.timezone / 60 / 60;
|
|
|
|
}
|
|
|
|
let timeZoneStr = timeZoneValue.toString();
|
|
|
|
return dateTimeUTC(timeZoneStr);
|
|
|
|
}
|