Closed GloryAmateure closed 1 year ago
Guck mal ob die Version dir hilft, eventuell veröffentliche ich dies als Version v2
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-green; icon-glyph: birthday-cake;
// Author roflrolle
// Github: https://github.com/roflrolle/Scriptable
// change values here if neeeded:
// maximum bdays to be displayed
const maxvalues=3
// Birthday in your language
const bdaytext="Geburtstage"
const color_bg = "#181919"
const color_head= "#fff"
const color_text="#fff"
const color_subtext="#808080"
const color_daysleft="#ffff00"
const fontsize_head= 16
const font_head=""
const font_text=""
const font_subtext=""
const fontsize_text=12
const fontsize_subtext=11
const fontsize_subtext2=8
// #############################
const list = new ListWidget()
let now= new Date()
minutes=180
let then= new Date(now.getTime() + minutes*60000)
list.refreshAfterDate=then
list.backgroundColor=new Color(color_bg)
const header=list.addText("🎂 "+bdaytext)
header.textColor=new Color(color_head)
header.font = new Font(font_head,fontsize_head)
list.addSpacer(5)
let containers = await ContactsContainer.all();
let contacts = await Contact.all(containers);
var array= []
contacts.forEach(function(contact){
if(contact.birthday){
var datenow= new Date()
var date= new Date(contact.birthday)
var agetemp= new Date(Date.now()-date.getTime())
var bdayyear=(new Date(agetemp)).getUTCFullYear()
var age=Math.abs(bdayyear - 1970)+1
if(date.getFullYear() == 1){
date.setDate(date.getDate() + 2)
date.setFullYear(1900)
}
var temp1 = new Date()
var temp2 = new Date(contact.birthday)
if(temp2.getFullYear() == 1){
temp2.setDate(temp2.getDate() + 2)
}
temp1.setFullYear(2020)
temp1.setHours(0)
temp1.setMinutes(0)
temp1.setSeconds(0)
temp2.setFullYear(2020)
temp2.setHours(0)
temp2.setMinutes(0)
temp2.setSeconds(0)
var Difference_In_Time = temp2.getTime() - temp1.getTime();
var Difference_In_Days = Difference_In_Time / (1000 * 3600 * 24);
Difference_In_Days=Math.round(Difference_In_Days,2)
array.push(Difference_In_Days+";"+contact.givenName+" "+contact.familyName+";"+date+";"+age)
}
})
array.sort(function(a, b){return a.split(";")[0] -b.split(";")[0]})
var x=0
array.forEach(function(element){
var birthday= new Date(element.split(";")[2])
var Name = element.split(";")[1]
var DaysTill= element.split(";")[0]
var alter = element.split(";")[3]
if(DaysTill >= 0){
x+=1
if(x <=maxvalues){
const label = list.addText(Name)
label.font = new Font(font_text,fontsize_text)
label.textColor=new Color(color_text)
const form=new DateFormatter()
form.dateFormat="dd.MM.yyyy"
const bday = list.addText( form.string(birthday))
bday.font = new Font(font_subtext,fontsize_subtext)
bday.textColor=new Color(color_subtext)
bday.rightAlignText()
const left= list.addText(alter+" Jahre alt in "+DaysTill+" Tagen ")
left.font = new Font(font_subtext,fontsize_subtext2)
left.textColor=new Color(color_daysleft)
left.rightAlignText()
}
}
})
if (!config.runsInWidget) {
list.presentSmall()
}
Script.setWidget(list)
Script.complete()
So habe ich mir das vorgestellt. Jetzt weiß man auch wann eine große Party ansteht. Ja als Version 2 kann man das schon rausbringen
Passt dann schließ ich das issue.
Muss noch Internationalisierung hinzufügen dann mach ich Evtl v2 draus. Danke fürs Feedback
Neue version ist online
Tach habe viel gebastelt bekomme leider oft eine Fehler Meldung… Ziel : Das Alter vom Kontakt das es angezeigt wird. Am besten ganz unten unterm Datum