In fact, it is accurate to the week, that is, given the current time, know the first week of the semester. the key to the problem seems to be that the rule is not found. I am using the following code (php), which is not accurate enough: {code ...} in fact, it is accurate to the week, that is, given the current time, know the first week of the semester. the key to the problem seems to be that the rule is not found. I am using the following code (php), which is not accurate enough:
function teachweek ($date){ $timestamp=strtotime($date); if (date('m', $timestamp)>=9){ return date('W', $timestamp)-35; }elseif(date('m', $timestamp)<=2){ return date('W', $timestamp)+18; }else{ return date('W', $timestamp)-7; }}
Reply content:
In fact, it is accurate to the week, that is, given the current time, know the first week of the semester. the key to the problem seems to be that the rule is not found. I am using the following code (php), which is not accurate enough:
function teachweek ($date){ $timestamp=strtotime($date); if (date('m', $timestamp)>=9){ return date('W', $timestamp)-35; }elseif(date('m', $timestamp)<=2){ return date('W', $timestamp)+18; }else{ return date('W', $timestamp)-7; }}
The inaccuracy should be due to the Numbers 35 and 18. In addition, if the year September 1 is Saturday or Sunday, it cannot be counted as the first week, you can first determine the week of the year September 1.
$thisyear=date('Y',strtotime($date));$ondate=date('W',strtotime("1 September $thisyear"));
In this way, the fourth line can be replaced
return date('W', $timestamp)-$ondate+1;
Whether or not + 1 is determined by determining whether or not September 1 is Saturday or not. I will not write it here;
If the date is before the winter vacation at the beginning of the year, you also need to calculate the number of weeks from January 1, September 1 last year to January 1, December 31.
$lastyear=date('Y',strtotime($date))-1;$lastyearweeks=date('W',strtotime("31 December $lastyear"))-date('W',strtotime("1 September $lastyear"))+1;
Similarly, whether + 1 needs to be determined by determining whether or not September 1 is Saturday/day, so that the sixth line can be replaced
return (date('W', $timestamp)%53)+$lastyearweeks;
Similarly, if you determine the start date of the second semester, you can determine the week of the second semester by modifying 7 in the last retrun.
You are all confused by the surface demand. If you ask the current date as the first month of the start date, although the logic of the landlord and the first floor is not completely correct, it is okay to modify it, however, the week is unnecessary, because the key to the problem is that 7 days is a week. My pseudo code is as follows:
$ StartDate = start date; // For example, $ startDay = start Day is the day of the week; // For example, 3 indicates week 3 $ limitDay = today is the day since 1970-The start date is the day since 1970; // For example, 55 days on Sunday is the first day of every week, it does not make sense to consider this question.) $ weekNumber = ceil ($ limitDay + $ startDay)/7); // because the first week of school may not be the whole week, so add the number of days lost
$ WeekNumber is what you want
Thank you for your contribution. I think you can make an analysis from the following table (# Note ):
Year |
(Spring) class date |
(Spring) teaching week count |
Summer vacation begins |
(Autumn) class date |
(Autumn) teaching week count |
Winter vacation begins |
New Year's Eve: the day of the week |
2010 |
3/1 |
21 |
7/25 |
8/30 |
20 |
1/15 |
2/2: 3 |
2011 |
2/21 |
18 |
6/25 |
8/29 |
20 |
1/15 |
1/22: 7 |
2012 |
2/13 |
18 |
6/17 |
9/3 |
21 |
1/26 |
2/9: 6 |
2013 |
2/25 |
18 |
6/29 |
9/2 |
20 |
1/18 |
1/30: 4 |
2014 |
2/17 |
18 |
6/21 |
9/1 |
22 |
1/31 |
2/18: 3 |
2015 |
3/2 |
18 |
7/4 |
8/31 |
21 |
1/23 |
2/8: 1 |
2016 |
2/22 |
18 |
6/25 |
8/29 |
The analysis shows that we can analyze the New Year's Day first, and then decide the summer vacation by the two weeks before and after the New Year's Day. here we need to make some details, for example, the New Year is related to the day of the week.
Which of the following is the last Monday to start school in the fall?
In spring, is the start date determined by the Chinese New Year )?
(# Note: the statistical results may not be very correct. You can review them .)
Does this need to be done using algorithms or algorithms? Is it enough to directly record the time of the school calendar to the database?
The school records a single year, that is to say, once a year. To put it bluntly, there is no rule at all. This is what the Academic Affairs Office decides.
I really thought that the Chinese new year's festival was held for all colleges and universities in China in September 1. I have never completed the Lantern Festival at home in a certain 985 colleges and universities.