Fortune Telling Collection - Zodiac Analysis - How to calculate the constellation by date
How to calculate the constellation by date
Start Month Constellation End Month Time Interval 1222 Capricorn12/22-119120 Aquarius 2181 20426543822923 Libra10229/22-1221023 Scorpio1122-1.
Abstract an array
C = [Capricorn, Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Lion, Virgo, Libra, Scorpio, Sagittarius, Capricorn] C is the monthly list.
The Aquarius with the serial number 1 in this array corresponds to the starting month of 1.
Serial number is the starting month or (ending month-1).
The starting month of the constellation corresponding to the date is the month in which the date is located or the ending month is this month (that is, the starting month is the month in which the date is located-1).
In order to get the constellation corresponding to the date, we calculate the starting month of the corresponding constellation through the date.
start month = month-[(day & lt; Date [month])? 1 : 0]
C = [Capricorn, Aquarius, Pisces, Aries, Taurus, Gemini, Cancer, Lion, Virgo, Libra, Scorpio, Sagittarius, Capricorn]
Index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,1,12]
Date = [22, 20, 19, 2 1, 2 1, 2 1, 22, 23, 22]start month- the starting month of the corresponding constellation after calculation;
Month-the month corresponding to the date;
Day-a number corresponding to the date;
Date-A list of dates corresponding to the month list;
Explanation:
The starting month of the corresponding constellation = current month-[(whether the current date is less than the date of the corresponding month) is 1, otherwise it is 0].
Judge (the number of days corresponding to the number
For example, February 18 is Aquarius, and February 19 is Gemini.
18 & lt; 19 (19 is the starting date of Pisces in February) is less than 2- 1 = 1. The corresponding constellation in January is Aquarius.
19 = 19 is less than invalid, and 2-0 = 2, so it is Pisces corresponding to February.
Simplified list cancellation date list.
Day< date [month] = "day-x < Date [month]-x
Let y = Date[month]-x, and y needs to be a single digit.
At present, the minimum number corresponding to the start date is 19 (Pisces) and the maximum number is 23 (Leo).
Be exhaustive and list the forms.
xyx+y = 19 xyx+y = 23 109
149√ 1 18
158√ 127
167√ 136
176√ 145√ 185√ 154√ 194√ 163√203
172√2 12
18 1√22 1
190√230
The intersection of two columns X is 14-19.
Take x = 14.
Date = [22,20, 19,2 1,2 1,2 1,22,23,23,23,23,22,22]date - 14
The final list is 8, 6, 5, 7, 7, 8, 9, 9, 8, 8 = >' 86577899988'
start month = month-[(day & lt; Date [month])? 1 : 0]
=> month-(day-14 <; 865778999988'.charAt (month))
True automatically becomes1;
True automatically becomes 0;
CharAt is the final code of str, which is used to find the corresponding position of the string.
var date = new Date(20 17, 1, 12);
//Set the date
Function to get constellation (date) (
Var c = ['Capricorn',' Aquarius',' Pisces',' Aries',' Taurus',' Gemini',' Cancer',' Lion',' Virgin',' Libra',' Scorpio',' Sagittarius',' Capricorn']
var month = date . getmonth()+ 1;
var day = date . getdate();
var start month = month-(day- 14 & lt; 865778999988'.charAt (month));
Return c[ start month]
}
Get ostograph (date);
//water bottle
- Previous article:1993 65438+ What is the constellation in February?
- Next article:What do you think of Mercury? What do you think of Mercury?
- Related articles
- Take you to "Hi" Ottawa Winter Carnival?
- A constellation man who is too controlling and annoying, but determined to succeed
- Saint saint seiya ol- the essence of people.
- How to break up with Virgo
- What constellation does Leo match?
- What constellation was born in 2005? Lucky day is a flower of luck.
- How to tell the true feelings or false feelings of 12 constellation men?
- Lv Lijun obviously lost to Gambi, but now life in Lv Lijun is the real life. what do you think?
- Which constellation is Scorpio fascinated by?
- What constellation can't let go after breaking up?