Skip to content

Instantly share code, notes, and snippets.

@alex-gist
alex-gist / gist:2023275
Created March 12, 2012 16:47 — forked from shreyas-satish/gist:1381897
JavaScript: Date validator
function isValidDate(date) {
var matches = /^(\d{2})[-\/](\d{2})[-\/](\d{4})$/.exec(date);
if (matches == null) return false;
var d = matches[1];
var m = matches[2] - 1;
var y = matches[3];
var composedDate = new Date(y, m, d);
return composedDate.getDate() == d && composedDate.getMonth() == m && composedDate.getFullYear() == y;
}
@alex-gist
alex-gist / dateExtend.js
Created March 12, 2012 16:47 — forked from rwbaker/dateExtend.js
JavaScript: Extend JavaScript Date
//Extend Date to have a few extra fatures
Date.dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
Date.monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
Date.prototype.dayNames = Date.dayNames;
Date.prototype.monthNames = Date.monthNames;
Date.prototype.getDayName = function() {
return this.dayNames[this.getDay()];
};
Date.prototype.getDayNameAbbr = function() {
@alex-gist
alex-gist / Date.js
Created March 12, 2012 16:46 — forked from jsmecham/Date.js
JavaScript: Date Formatter
/**
* Date#strftime(format) -> String
*
* - format (String): the format string
*
* Formats the *date* according to the directives given in the *format*
* string. Requires a String#interpolate() extension.
*
* ## Format Components
*
@alex-gist
alex-gist / boilerplate.html
Created March 12, 2012 16:40
HTML: Starter Boilerplate (HTML 5)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>HTML5 boilerplate—all you really need…</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>