LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is strftime () ISO 8601 compliant?

Apparently not. The week of year can be calculated with two formatting codes: %U (for which the first week has the first Sunday) and %W (week 1 has the first Monday). On both cases, previous days are week 0.

Iso standard states that week 1 has the first Thursday, previous days are considered pertaining to the last week of the previous year. Besides it, a week starts on Sunday in strftime and on Monday in ISO standard.

Now the question is: is there a consolidated algorithm to calculate ISO week number? I found this link but I will like to be corroborated in my investigations.

Another question: will strftime be updated in the future? Some implementations of C libraries introduced a %V formatting code (look for example at this site) to return the ISO week number but seems that strftime (at least as of CVI 7.0.0) does not recognize it.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 1 of 6
(4,436 Views)

And 7 years later apparently still not... Just tried %F %T %z, etc... without success. Does this need a Idea Exchange entry ?

 

Also there's no strptime() to do the converse of strftime(). But maybe there's a #define that secretly activates ISO 8601 ?

 

With gcc I think strptime needs _XOPEN_SOURCE, but I haven't tried it.

0 Kudos
Message 2 of 6
(3,587 Views)

In the meanwhile, I wrote some line of code to calculate the week number according to ISO 8601: you can find it here



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 6
(3,573 Views)

It's 2022 and they still haven't implemented it.  I was wondering if there is a way to use Windows SDK version instead of the CVI version of strftime().

0 Kudos
Message 4 of 6
(1,765 Views)

Except for the week numbers you can just use %Y-%m-%d instead of %F.

If the week numbers are important, long ago (30 years!) I wrote an addition to strftime that added several scientific formats. You could just use and modify that source code instead of messing around with the WSDK...

 

Note that with recent GCC you can customize format specifiers for printf, but some time ago I wanted to rewrite my StrfTime function this way and found out that it is not (yet?) implemented for strftime.

0 Kudos
Message 5 of 6
(1,754 Views)

I just rolled my own a long time ago. Enjoy.

0 Kudos
Message 6 of 6
(1,628 Views)