JavaScript Zodiac Sign: Get the Zodiac sign for a given date

Recommend this page to a friend!
     
  Info   Example   View files Files   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 133 All time: 365 This week: 3Up
Version License JavaScript version Categories
zodiac-sign 1.0Artistic License1.0Time and Date
Description 

Author

The component can get the Zodiac sign for a given date.

It extends the JavaScript Date object to get the Zodiac date for the current date.

It provides two functions that return the name of the date Zodiac sign in English and French.

Innovation Award
JavaScript Programming Innovation award winner
August 2014
Winner


Prize: One downloadable e-book of choice by O'Reilly
Zodiac signs are entities that are associated to people that was born in different dates of the year.

This object can compute the Zodiac sign of a person given his birth date.

Manuel Lemos
Picture of Pierre FAUQUE
Name: Pierre FAUQUE <contact>
Classes: 3 packages by
Country: France France
Age: 77
All time rank: 935 in France France
Week rank: 6 Up2 in France France Up
Innovation award
Innovation award
Nominee: 3x

Winner: 2x

Recommendations

Horoscope birth chart
horoscope birth chart script

Example

<html> <head> <script language="javascript" type="text/javascript"> // For English users: getSign() Date.prototype.getSign=function(){var zodiaque=new Array("aries","taurus","gemini","cancer","leo","virgo","libra","scorpio","sagittarius","capricorn","aquarius","pisces"),d,w,m;d=(367*this.getFullYear()-Math.floor((7*(this.getFullYear()+Math.floor((this.getMonth()+1+9)/12)))/4)+Math.floor((275*(this.getMonth()+1))/9)+this.getDate()-730530);w=(282.9404+4.70935E-5*d)-Math.floor((282.9404+4.70935E-5*d)/360.0)*360.0;m=(356.0470+0.9856002585*d)-Math.floor((356.0470+0.9856002585*d)/360.0)*360.0;return zodiaque[Math.floor(((w+m)-Math.floor((w+m)/360.0)*360.0)/30.0)];}; </script> <script language="javascript" type="text/javascript"> //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Test the validity of a French date (JJ/MM/AAAA). // Return "OK" or an error message // You can interchange the lines 19 and 20 (with indices correction) for a format such as MM/DD/AAAA function isValidDate(date) { var date, tab, reg = new RegExp("^[0-9]{2}[/]{1}[0-9]{2}[/]{1}[0-9]{4}$","g"); if(reg.test(date)) { tab=date.split('/'); if((tab[0]*1)<1 || (tab[0]*1)>31) { return "Incorrect day"; } // 19 if((tab[1]*1)<1 || (tab[1]*1)>12) { return "Incorrect month"; } // 20 return "OK"; } return "Incorrect format date"; } function sign() { var thedate, date, tab; date=document.test.date.value; tab=date.split('/'); j=tab[0]*1; m=tab[1]-1; a=tab[2]*1; thedate = new Date(a, m, j); signe = thedate.getSign(); alert('People who are born on '+date+' are '+thedate.getSign()); } // ========================================================================================= function verif() { var thedate; // get the values of the form thedate = document.test.date.value; if(!thedate) { alert('Date is missing'); document.test.date.focus(); return false; } msg = isValidDate(thedate); if(msg != "OK") { alert("Date :\n"+msg); document.test.date.focus(); return false; } return true; } </script> </head> <body> <h3>Signe du zodiaque</h3> <form name="test" method="post" action="javascript:sign()" onsubmit="return verif()"> Write a date (DD/MM/AAAA) <input type="text" name="date" size="10"><input type="submit" name="submit" value="Validate"> </form> </body> </html>

  Files folder image Files (2)  
File Role Description
Accessible without login Plain text file example.html Example Example of use
Plain text file getSign.js Class main Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:133
This week:0
All time:365
This week:3Up