Thanks for the post. I think you could improve it by removing the hardcoded English day names and using the JS built-in features to get the day of the week in your locale.
Typescript:
getWeekDays(locale):string[]{varbaseDate=newDate(Date.UTC(2017,0,1));// just a SundayvarweekDays=[];for(leti=0;i<7;i++){letdayName=baseDate.toLocaleDateString(locale,{weekday:'long'});dayName=dayName[0].toUpperCase()+dayName.slice(1);weekDays.push(dayName);baseDate.setDate(baseDate.getDate()+1);}returnweekDays;}
Thanks for the post. I think you could improve it by removing the hardcoded English day names and using the JS built-in features to get the day of the week in your
locale
.Typescript:
Great i did not know that. Thanks 😀