10-03-2014 09:22 AM
I need a function to determine which weekday is the first in (any) month, how many days in that month and whitch week numbers accosiated.
Anyone with a good idea ?
10-03-2014 09:40 AM - edited 10-03-2014 09:41 AM
You can use one of my contributions to get the week number given a date.
In that code you can get also an idea as to how to calculate the lenght of february given the year with the appropriate leap year adjustment.
You can get the day of week by calling mktime () function: fill in the date fields and pass the struct to the function that will calculate and update the struct for the day of the week.
10-03-2014 12:19 PM
Hi Roberto
I'm using another of your contribution.
http://forums.ni.com/t5/LabWindows-CVI/ISO-week-number/m-p/119010/highlight/true#M9735
If I could get the day of week also it would be good enough. I does not seem that tm_wday gets update with mktime()
The input to the modified function is day,month,year (day 1-31, month 1-12) . The week is calculated but I need the day of week .
10-06-2014 02:52 AM
On my machine mktime is working correctly.
This code can be pasted and executed in the Interactive Execution window: does it return any error? Code queries for today and should return day #1 of week, that is monday.
#include <utility.h> #include <ansi_c.h> #include <time.h> static time_t k; static struct tm y; memset (&y, 0, sizeof (struct tm)); y.tm_mday = 6; y.tm_mon = 9; y.tm_year = 114; y.tm_hour = 9; k = mktime (&y); if (k == -1) DebugPrintf ("Error in mktime function\n"); else { DebugPrintf ("Day of week; %d\n", y.tm_wday); DebugPrintf ("Daylight savings time: "); if (y.tm_isdst > 0) DebugPrintf ("Effective\n"); else if (!y.tm_isdst) DebugPrintf ("Not effective\n"); else DebugPrintf ("Unknown\n"); }