C # implementation based on the month of the day, the function of the week is selected from the blog of Fanz2000

xiaoxiao2021-03-06  40

The algorithm is as follows: Kelason Computational Formula W = (D 2 * m 3 * (M 1) / 5 Y Y / 4-Y / 100 Y / 400) MOD 7 in the formula D The number of days in the date, M represents the number of months, y indicates the number of years. Note: There is a different place in the formula: seeing January and February as the last year of the last year of the last year of the last year of the last year of the last year of the last year, the example: If it is 2004-10, the exchange is: 2003- 13-10 Come to the formula calculation. The code is as follows: // Y-year, M-month, D-date String Caculateweekday (int y, int m, int d) {if (m == 1) m = 13; if (m == 2) m = 14 ; Int week = (D 2 * m 3 * (m 1) / 5 y y / 4-y / 100 y / 400)% 7; string weekstr = ""; switch (week) {cas 1: Weekstr = "Monday"; Break; Case 2: Weekstr = "Tuesday"; Break; Case 3: Weekstr = "Wednesday"; Break; Case 4: Weekstr = "Thursday"; Break; Case 5: Weekstr = " Friday "; Break; Case 6: Weekstr =" Saturday "; Break; Case 7: Weekstr =" Sunday "; Break;} Return Weekstr;} Call method: label2.text = CaculateWeekDay (2004, 12, 9);

Author Blog:

http://blog.9cbs.net/fanz2000/

related articles

C # Implementation According to the month of the day, the function of the week is not available. No SQL statement query DataTable data [Original] Programming Data Learning Gold Flat [Reposted] Multi-level directory database design C # implementation lists All subdirectories and Document program (attachment road)

转载请注明原文地址:https://www.9cbs.com/read-78540.html

New Post(0)