int GetWeekNumber(int year, int month, int day) { // 週數計算 int lval_tempDayofYear = 0; int lvar_tempWeekNumber = 0; int lvar_ShiftDayOfWeek = QDate(year,1,1).dayOfWeek(); // 1月1日之星期幾 int lval_AddWeekNumber = 0; if (lvar_ShiftDayOfWeek < 4) // 1月1日在周四之前 { // 第一周在1月1日,否則在前一年之最後一周 lval_AddWeekNumber = 1; } else { lval_AddWeekNumber = 0; } lval_tempDayofYear = QDate(year,month,day).dayOfYear(); lvar_tempWeekNumber = ((lval_tempDayofYear + lvar_ShiftDayOfWeek - 1) / 7) + lval_AddWeekNumber; if (lvar_tempWeekNumber == 0) { return(GetWeekNumber(year-1, 12, 31)); } return (lvar_tempWeekNumber); }