My favorites
▼
|
Sign in
fullcalendar
ISSUE TRACKER HAS MOVED. DO NOT USE THIS (more info)
Project Home
Issues
Export to GitHub
New issue
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
1076
attachment: parseDate.js
(1.2 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
if (typeof s == 'object') { // already a Date object
return s;
}
if (typeof s == 'number') { // a UNIX timestamp
if( ignoreTimezone == true ){
var lclDate = new Date(s * 1000);
return new Date( lclDate.valueOf() + ( lclDate.getTimezoneOffset() * 60 *1000 ) );
}
else{
return new Date(s * 1000);
}
}
if (typeof s == 'string') {
if (s.match(/^\d+(\.\d+)?$/)) { // a UNIX timestamp
if( ignoreTimezone == true ){
var lclDate = new Date(parseFloat(s) * 1000);
return new Date( lclDate.valueOf() + ( lclDate.getTimezoneOffset() * 60 *1000 ) );
}
else{
return new Date(parseFloat(s) * 1000);
}
}
if (ignoreTimezone === undefined) {
ignoreTimezone = true;
}
return parseISO8601(s, ignoreTimezone) || (s ? new Date(s) : null);
}
// TODO: never return invalid dates (like from new Date(<string>)), return null instead
return null;
}
Powered by
Google Project Hosting