src/lib/btime.c
int tm_woy(time_t stime)
{
   int woy, fty, tm_yday;
   time_t time4;
   struct tm tm;

   memset(&tm, 0, sizeof(struct tm));
   (void)localtime_r(&stime, &tm);
   tm_yday = tm.tm_yday;
   tm.tm_mon = 0;
   tm.tm_mday = 4;
   tm.tm_isdst = 0;                   /* 4 Jan is not DST */
   time4 = mktime(&tm);
   (void)localtime_r(&time4, &tm);
   fty = 1 - tm.tm_wday;
   if (fty <= 0) {
      fty += 7;
   }
   woy = tm_yday - fty + 4;
   if (woy < 0) {
      return 0;
   }
   return 1 + woy / 7;
}
/*
 * Given a Unix date return the week of the year.
 * The returned value can be 0-53.  Officially
 * the weeks are numbered from 1 to 53 where week1
 * is the week in which the first Thursday of the
 * year occurs (alternatively, the week which contains
 * the 4th of January).  We return 0, if the week of the
 * year does not fall in the current year.
 */
Given a Unix date return the week of the year.
The returned value can be 0-53.  Officially
the weeks are numbered from 1 to 53 where week1
is the week in which the first Thursday of the
year occurs (alternatively, the week which contains
the 4th of January).  We return 0, if the week of the
year does not fall in the current year.
Given a Unix date return the week of the year . The returned value can be 0 - 53 . Officially the weeks are numbered from 1 to 53 where week1 is the week in which the first Thursday of the year occurs ( alternatively the week which contains the 4th of January ) . We return 0 if the week of the year does not fall in the current year .
int tm_woy(time_t stime)
{
   int woy, fty, tm_yday;
   time_t time4;
   struct tm tm;
   memset(&tm, 0, sizeof(struct tm));
   (void)localtime_r(&stime, &tm);
   tm_yday = tm.tm_yday;
   tm.tm_mon = 0;
   tm.tm_mday = 4;
   tm.tm_isdst = 0;                   
   time4 = mktime(&tm);
   (void)localtime_r(&time4, &tm);
   fty = 1 - tm.tm_wday;
   if (fty <= 0) {
      fty += 7;
   }
   woy = tm_yday - fty + 4;
   if (woy < 0) {
      return 0;
   }
   return 1 + woy / 7;
}
int tm_woy ( time_t stime ) { int woy , fty , tm_yday ; time_t time4 ; struct tm tm ; memset ( & tm , 0 , sizeof ( struct tm ) ) ; ( void ) localtime_r ( & stime , & tm ) ; tm_yday = tm . tm_yday ; tm . tm_mon = 0 ; tm . tm_mday = 4 ; tm . tm_isdst = 0 ; time4 = mktime ( & tm ) ; ( void ) localtime_r ( & time4 , & tm ) ; fty = 1 - tm . tm_wday ; if ( fty <= 0 ) { fty += 7 ; } woy = tm_yday - fty + 4 ; if ( woy < 0 ) { return 0 ; } return 1 + woy / 7 ; }
Given a Unix date return the week of the year.
Given a Unix date return the week of the year .
/* 4 Jan is not DST */