topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday April 16, 2021, 9:52 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - henriko [ switch to compact view ]

Pages: [1]
1
T-Clock / Re: T-Clock 2010 (download) - Week number - ISO-8601
« on: February 27, 2013, 05:16 AM »
Hi Stoic Joker, and others. I'm not sure if there are going to be any more "official" builds from you, or if the project really is closed. But anyway. If someone will make a new build, here is a contribution to format.c , that will provide week numbers according to the ISO-8601 standard.

I hope that someone can make some use of it, and in that case document the feature where it should be documented. I have chosen Wi as the new format identifier for ISO-8601 week number.

It might be used like this:
vWi yymmdd hh:nn
v9 130217 12:14

format.c diff
535a536,613
> else if(*(sp + 1) == 'i') { // Week ISO-8601 (by henriko.se)
> int ISOWeek;
> struct tm *ptrtmLocalTime;
> struct tm tmCurrentTime;
> struct tm tmStartOfCurrentYear;
> ptrtmLocalTime = localtime(&ltime);
> tmCurrentTime = *ptrtmLocalTime;
> mktime(&tmCurrentTime);
> if(tmCurrentTime.tm_wday == 0)
> {
> tmCurrentTime.tm_wday = 7;
> }
> tmStartOfCurrentYear.tm_year = tmCurrentTime.tm_year;
> tmStartOfCurrentYear.tm_mon = 1 - 1;
> tmStartOfCurrentYear.tm_mday = 1;
> tmStartOfCurrentYear.tm_hour = 0;
> tmStartOfCurrentYear.tm_min = 0;
> tmStartOfCurrentYear.tm_sec = 0;
> tmStartOfCurrentYear.tm_isdst = 0;
> mktime(&tmStartOfCurrentYear);
> if(tmStartOfCurrentYear.tm_wday == 0)
> {
> tmStartOfCurrentYear.tm_wday = 7;
> }
> ISOWeek = (tmCurrentTime.tm_yday + (tmStartOfCurrentYear.tm_wday - 1)) / 7 + (tmStartOfCurrentYear.tm_wday <= 4 ? 1 : 0);
> if(ISOWeek == 0)
> {
> struct tm tmStartOfLastYear;
> struct tm tmEndOfLastYear;
> tmStartOfLastYear.tm_year = tmCurrentTime.tm_year - 1;
> tmStartOfLastYear.tm_mon = 1 - 1;
> tmStartOfLastYear.tm_mday = 1;
> tmStartOfLastYear.tm_hour = 0;
> tmStartOfLastYear.tm_min = 0;
> tmStartOfLastYear.tm_sec = 0;
> tmStartOfLastYear.tm_isdst = 0;
> mktime(&tmStartOfLastYear);
> if(tmStartOfLastYear.tm_wday == 0)
> {
> tmStartOfLastYear.tm_wday = 7;
> }
> tmEndOfLastYear.tm_year = tmCurrentTime.tm_year - 1;
> tmEndOfLastYear.tm_mon = 12 - 1;
> tmEndOfLastYear.tm_mday = 31;
> tmEndOfLastYear.tm_hour = 0;
> tmEndOfLastYear.tm_min = 0;
> tmEndOfLastYear.tm_sec = 0;
> tmEndOfLastYear.tm_isdst = 0;
> mktime(&tmEndOfLastYear);
> ISOWeek = (tmEndOfLastYear.tm_yday + (tmStartOfLastYear.tm_wday - 1)) / 7 + (tmStartOfLastYear.tm_wday <= 4 ? 1 : 0);
> }
> if(tmCurrentTime.tm_mon == 12 - 1 && tmCurrentTime.tm_mday >= 29) {
> if(tmCurrentTime.tm_wday <= 3)
> {
> struct tm tmStartOfNextYear;
> tmStartOfNextYear.tm_year = tmCurrentTime.tm_year + 1;
> tmStartOfNextYear.tm_mon = 1 - 1;
> tmStartOfNextYear.tm_mday = 1;
> tmStartOfNextYear.tm_hour = 0;
> tmStartOfNextYear.tm_min = 0;
> tmStartOfNextYear.tm_sec = 0;
> tmStartOfNextYear.tm_isdst = 0;
> mktime(&tmStartOfNextYear);
> if(tmStartOfNextYear.tm_wday == 0)
> {
> tmStartOfNextYear.tm_wday = 7;
> }
> if(tmStartOfNextYear.tm_wday <= 4)
> {
> ISOWeek = 1;
> }
> }
> }
> wsprintf(szWkNum, "%d", ISOWeek);
> Wk = szWkNum;
> while(*Wk) *dp++ = *Wk++;
> sp++;
> }

Pages: [1]