puredate.js
Now is very easy manipulate date without time in javascript.
puredate.js serves to manipulate simple dates in javascript. This is very useful when you don't need worry about time and timezone. The PureDate object is ideal to manipulate birthdays and other dates that are recorded in documents.
Oficial webpage and examples: http://sergio.figueiredo.nom.br/puredate
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
CHANGELOG
Check Releases
Instalation
There are 2 ways for instalation:
For bower users:
bower install puredate
Downloading the script:
Download 'puredate.js' file and enjoy.
Syntax
var puredate = PureDate; orvar puredate = PureDate; orvar puredate = PureDate;
Property list:
var today = PureDate;document;document; /* note: gdate is a integer number of days since March, 1 /0000 you can use gdate number to store puredate in a database or send to network.*/
Method list:
var today = PureDate;var tomorrow = today; // add 1 day var nextMonth = today; // add 1 month. var dow = today // return 0 for Sunday , 1 for Monday, ... 6 for Saturdayvar isLeapYear = today // true if this date is in a leap year.var firstDayOfMonth = today // returns day 1 of same month and year var firstDayofYear= today // returns day 1 and month 1(january) of same yearvar lastDayOfMonth = today // returns the last day of month.var lastDayOfYear = today // returns the 31 of december of today's year.// note: today variable value remains immutable after all methods execution.
Constant list:
// monthsPureDateJANUARY:1PureDateFEBRUARY:2PureDateMARCH:3PureDateAPRIL:4PureDateMAY:5PureDateJUNE:6PureDateJULY:7PureDateAUGUST:8PureDateSEPTEMBER:9PureDateOCTOBER:10PureDateNOVEMBER:11PureDateDECEMBER:12// weekdaysPureDateSUNDAY:0PureDateMONDAY:1PureDateTUESDAY:2PureDateWEDNESDAY:3PureDateTHURSDAY:4PureDateFRIDAY:5PureDateSATURDAY:6
Examples
Today date
var today = PureDate;
Specific Date
var specDate = PureDate;
Reading properties
var today = PureDate;var year = todayyear;var month = todaymonth;var day = todayday;
adding a month
var today = PureDate;var nextMonth = today;
Note: today instance is not modified. The PureDate object are immutable.
day of week
var today = PureDate;if today === PureDateSUNDAY ;
Note: today instance is not modified. The PureDate object are immutable.
require.js
This javascript can be used with require.js. Their use is optional.
Description
This code uses gdate algorithm to convert day, month and year in a integer number thats is de day number since March, 1, year 0. You can read the gDate value and store it in a database. To restore this integer in a date is easy:
var gdate = 735935; // Feb, 1, 2015var date = ;
Index of Months
- January is month 1;
- December is month 12;
Limitations
The simplicity of this code costs some limitations for their use.
This object only refers to a Gregorian Calendar, so this will work fine for any date since the adoption of Gregoria Calendar. Warning: each country has a diferent date of adotion of this calendar. The older countries adopt this calendar at Oct, 15, 1582 (Spain, Portugal, Italy, Polish).
That said, if you need to know precisaly how many days have passed of first arrival of the Portuguese fleet in Brazil (April, 22, 1500 year), you can not use this date, because the portugueses didn't use Gregorian Calendar at that time.