Hi
I m trying to find a way (an app) which could return the month, or whether its winter or summer time!
Any help would be welcome!
Hi Olivier,
Nice puzzle!
I created a script, you can use it in an Adv.flow like this:
// This script creates/updates a tag named NameOfMonth and DST time (Summer/Winter)
// USER INPUT
// Enter your wintertime timezone offset from UTC time, f.i. +1 (Paris), +2 (Helsinki), -3 (Rio de Janeiro)
var myOffset = +1;
// Optional: Enter your local translations
var Summer = "Summer/Zomer/Sommer/Été/El verano"
var Winter = "Winter/l'Hiver/Invierno"
// END OF USER INPUT
let SysInfo = await Homey.system.getInfo();
var tempS = SysInfo.dateHuman.slice(SysInfo.dateHuman.indexOf(' ')+1);
temp = tempS.slice(tempS.indexOf(' ')+1);
var MonthName = temp.slice(0,temp.indexOf(' '));
var theLocalHour = SysInfo.dateHuman.slice((SysInfo.dateHuman.length)-8,(SysInfo.dateHuman.length)-6);
const dateUTC = new Date();
var dst = "Something's wrong"
let utcHour = dateUTC.getUTCHours();
// adjust offset hours to your timezone
if ( myOffset == theLocalHour - utcHour ) { // The offset returned by this function = 0 while it = +1 in NL/Amsterdam
dst = Winter
}
else
dst = Summer;
//creating new HomeyScript Tag / Variable 'NameOfMonth'
await tag("NameOfMonth", MonthName);
//creating new HomeyScript Tag / Variable 'DST_time'
await tag("DST_time",dst);
// console.log("Month:", MonthName,"\nDST:",dst,"\n");
// Timestamps check
console.log("(Local hour="+theLocalHour,"| UTC hour="+utcHour+")");
return("Month: " + MonthName + ", " + "DST: " + dst);