Python realizes Apple (recursion)

2023-02-06   ES  

Week 1, January 1, 1 (Pianya)
Week 1 (Pianya), January 1, 2018 (year)

Calculation formula for the number of leap year before a certain year:
(y-1)/4 –(y-1)/100 + (y-1)/400

Calculating formula for the week on January 1, January 1st:
w = (y + (y-1)/4 –(y-1)/100 + (y-1)/400) % 7

Assuming the standard for 28 days a month, there is (Pingyan):
误差表-1

So there is a list of errors (flat year):
e[] = {0,3,3,6,1,4,6,2,5,0,3,5}

Algorithm on the week of each month on the 1st of each month (Pingyan):
w = (e[m-1] + y + (y-1)/4 –(y-1)/100 + (y-1)/400) % 7

The algorithm (including leap year) every month on the 1st of the month on the first month of the month:
w = (e[m-1] + y + y/4 –y/100 + y/400) % 7

(Among them, the week of January February of the leap year was -1, and the week of January February in the next year of the leap year was +1)

The first day of each year is March 1st, and January February of each year is used as January November. By January February of the BC), you need to re -derive.

Supplement assumption: March 1, 1st year 4 (Pianyan)

Calculating formula for the week of March 1st on March 1st:
w = (3 + y + (y-1)/4 –(y-1)/100 + (y-1)/400) % 7

New error list (Pingyan):
误差表-2
So there is a new list of errors (flat year):
e[] = {0,3,5,1,3,6,2,4,0,2,5,1}

Algorithm on the week of each month on the 1st of the month (Pingyan):
w = (e[m-3] + y + (y-1)/4 –(y-1)/100 + (y-1)/400) % 7

The algorithm (including leap year) every month on the 1st of the month on the first month of the month:
w = (e[m-3] + y + y/4 –y/100 + y/400) % 7

Considering the mapping “f: m -> e [m -3]”, the predecessors found out their relationship:
f(m) = -1 + 2m + 3(m+1)/5

关系检验

The algorithm (including leap year) every month on the 1st of the month on the 1st of each month:
w = (-1 + 2m + 3(m+1)/5 + y + y/4 –y/100 + y/400) % 7

The algorithm (including leap year) per day per month per month:
w = (d + 1 + 2m + 3(m+1)/5 + y + y/4 –y/100 + y/400) % 7

The algorithm (including leap year) every day every month per month:
w = (d + 2m + 3(m+1)/5 + y + y/4 –y/100 + y/400) % 7 + 1

test formula is established:

  1. Test on January 1, 1: 1: 1: 0 (pretending to exist) on January 1st year, and found it.
  2. Test on Sunday, October 12, 2018, it was found to be established.
  3. Test on Sunday, October 12, 2019, found out.
  4. Inspection on Sunday, October 12, 2020, it was found to be established.
  5. Inspection on October 12, 2021, 221, and found it.

w = (d + 2m + 3(m+1)/5 + y + y/4 – y/100 + y/400) % 7 + 1

Use conditions:

  1. 1 year and after the year.
  2. Calculate the data of the day of January February of the year to use the data of the previous year.
  3. result is a number of 1 to 7.
  4. Please give legal data. If I use “September 31, 2018”, I don’t know what to get.

[1] White Xiaobai Ani. Try to talk about Kimralson Date formula [eb/ol]. Https://blog.csdn.net/qq_33114231/artail/details/52352668. 2018-10-18.

Instructions:
This article summarizes the blog from CSDN blog owner Bai Xiaobai Ani,
There may be inadequate consideration, welcome to point out.

source

Related Posts

IOS development Homekit (2) lu

FLINK’s job submission and task scheduling wu

How to use ODX to describe diagnostic session and safety level

Analyze the AJAX request and capture “Today’s Headline’s Street Shooting”

Python realizes Apple (recursion)

Random Posts

vmware cloning CentOS7 virtual machine

Android adds bitmap to the overlay of View

date and time type

java swing to achieve a simple login interface WOO

Create uboot environment variable BIN file