PageRenderTime 101ms CodeModel.GetById 98ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/public/js/tablesorter/parsers/parser-date.js

https://gitlab.com/webster5361/UserFrosting
JavaScript | 35 lines | 25 code | 3 blank | 7 comment | 2 complexity | accaccb595fc16316267e12634f9a742 MD5 | raw file
 1/*! Parser: dates - updated 10/26/2014 (v2.18.0) */
 2/* Extract dates using popular natural language date parsers */
 3/*jshint jquery:true */
 4;(function($){
 5	'use strict';
 6
 7	/*! Sugar (http://sugarjs.com/dates#comparing_dates) */
 8	/* demo: http://jsfiddle.net/Mottie/abkNM/4163/ */
 9	$.tablesorter.addParser({
10		id: 'sugar',
11		is: function() {
12			return false;
13		},
14		format: function(s) {
15			var date = Date.create ? Date.create(s) : s ? new Date(s) : s;
16			return date instanceof Date && isFinite(date) ? date.getTime() : s;
17		},
18		type: 'numeric'
19	});
20
21	/*! Datejs (http://www.datejs.com/) */
22	/* demo: http://jsfiddle.net/Mottie/abkNM/4164/ */
23	$.tablesorter.addParser({
24		id: 'datejs',
25		is: function() {
26			return false;
27		},
28		format: function(s) {
29			var date = Date.parse ? Date.parse(s) : s ? new Date(s) : s;
30			return date instanceof Date && isFinite(date) ? date.getTime() : s;
31		},
32		type: 'numeric'
33	});
34
35})(jQuery);