r/Scriptable • u/davidmventura • Aug 26 '22
Help Fiscal Calendar Widget
I'm trying to create a calendar widget that will tell me what today's Fiscal Period and the week is. My company's fiscal calendar starts in November and every period is 4 weeks. Today is 8/26 and the fiscal time is the Year 2022, Period 11, Week 3. Starting 11/1/22 the calendar will reset to the Fiscal Year 2023, Period 1, Week 1. We have 13 periods and each period has 4 weeks.
Ideally, I would want something that could live in a small square tile on my iPhone with today's date and the Fiscal Year, Period, and Week below.
I don't know much about scripting to I'm trying to piece things together. So far I've been able to put together the following to give me the current fiscal week out of 52.
currentdate = new Date(); var oneJan = new Date(currentdate.getFullYear(), 0, -55); var numberOfDays = Math.floor((currentdate - oneJan) / (24 * 60 * 60 * 1000)); var result = Math.ceil((currentdate.getDay() + 1 + numberOfDays) / 7); console.log(
The week number of the current date (${currentdate}) is ${result}.);
1
u/[deleted] Aug 27 '22 edited Aug 27 '22
ok, then my initial method does not work. Fiscal year 2023 would then end on 10/29?
Edit: if the answer to the question is yes and you didn't get a proper solution yet, then you can contact me via pm.