If you try this:
you can see, the days of e.g. March are not correct because the daylight saving time has been changed here.
So try the following:
getDaysOfMonth.aia (11.8 KB)
If you try this:
you can see, the days of e.g. March are not correct because the daylight saving time has been changed here.
So try the following:
getDaysOfMonth.aia (11.8 KB)
Good work. But don't we really only need to check February? - assumes working with gregorian calendar - none of the other months change...
Yes, but if it were to be calculated (for whatever reason) the decisive factor here is daylight saving time, which, as I have shown, would repeatedly lead to errors in the calculation.
For example, if you want to get the duration from this:
You are getting an incorrect duration ... (missing 3600000 millis).
Ok, you create these dates, but there is no duration calculation.
By using the "day of the year" number, provided within the instant, you overcome any issues with DST (which is a PITA )
Since these values simply return: 1, 2, 3, ... 364, 365.
Another "method"
(draggable blocks, but you will need a clock component)
(the value 337 is the sum of all days in months except February)
Given that "we know" the number of days for each month apart from February, we could just get February:
@TIMAI2 I am showing to you a compact formula that works for any year, which has no Dragable Blocks
to work, which does not need to be modified, which still includes all the years in which February has 29 days within a huge spectrum, that works in all circumstances. But you are showing me another method that does not meet all these requirements... I do not understand... really...
I see no reason or advantage to stop using the formula I shared. ¯\﹏(ツ)﹏/¯
Lito
@>-->---
Which requirements does my method not meet? The only month that changes its number of days is February, so the procedure simply calculates that, based upon the year.
The draggable blocks are there so others can drag them into their projects, this is a community thing, nothing to do with the content.
As I said, what I offered is simply "another method", doesn't stop anyone using yours.
I also note, having tested your method, that it does not report the days in months correctly for 1700, 1800, 1900, 2100, 2200, 2300, none of which were leap years. (ref)
Maybe I need an award ?
@TIMAI2 Yes, you need. One day I will create an 'anti-Award' for you... ^^
Thanks for the tips to improve my formula. Now it works well for every year, don't need Clock
and the Procedure
returns the value to a specific year/month, without reading anything from a List
. The reason for reviving a 2020 topic is that I fell into it in a search and just wanted to share this solution, thinking it could be useful to someone.
My_Get_Days_of_Months.aia (3.7 KB)
My_Get_Days_of_Specific_Month.aia (3.6 KB)
Lito
@>-->---
Why not make a (draggable) procedure for your blocks in your first aia (and second aia), and post them here for each of use? Saves others having to download the aias and recreating blocks.
Why such a complex blocks or work around?
Whatever the year feb month alone days will change according to its leap. Ao prepare list of month days with 28 for feb. And if the year is leap change the feb month days alone to 29, thats all.
Initialise global variable to list from csv row text to 31,28,31,30,31,30,31,31,30,31,30,31
Check the input year as leap or not.
If yes change the index 2 with 29 else let it be as it is
I read through this thread and no one tried this idea
Return the number of days between the first day of next month and the first day of this month.
(Use Clock blocks)