diff --git a/docs/APIs/flickr/README.md b/docs/APIs/flickr/README.md
new file mode 100644
index 0000000..a013d9a
--- /dev/null
+++ b/docs/APIs/flickr/README.md
@@ -0,0 +1,148 @@
+
flickr API Reference
+Documentation generated: October 25, 2010 2:35am
+
+blogs
+
+ * getServices
+
+collections
+
+ * getTree
+
+commons
+
+ * getInstitutions
+
+contacts
+
+ * getPublicList
+
+favorites
+
+ * getPublicList
+
+galleries
+
+ * getInfo
+ * getList
+ * getListForPhoto
+ * getPhotos
+
+groups
+
+ * getInfo
+ * search
+
+ pools
+
+ * getContext
+ * getPhotos
+
+interestingness
+
+ * getList
+
+machinetags
+
+ * getNamespaces
+ * getPairs
+ * getPredicates
+ * getRecentValues
+ * getValues
+
+panda
+
+ * getList
+ * getPhotos
+
+people
+
+ * findByEmail
+ * findByUsername
+ * getInfo
+ * getPhotosOf
+ * getPublicGroups
+ * getPublicPhotos
+
+photos
+
+ * getAllContexts
+ * getContactsPublicPhotos
+ * getContext
+ * getExif
+ * getFavorites
+ * getInfo
+ * getRecent
+ * getSizes
+ * search
+
+ comments
+
+ * getList
+
+ get
+
+ * getLocation
+
+ licenses
+
+ * getInfo
+
+ people
+
+ * getList
+
+photosets
+
+ * getContext
+ * getInfo
+ * getList
+ * getPhotos
+
+ comments
+
+ * getList
+
+places
+
+ * find
+ * findByLatLon
+ * getChildrenWithPhotosPublic
+ * getInfo
+ * getInfoByUrl
+ * getPlaceTypes
+ * getShapeHistory
+ * getTopPlacesList
+ * placesForBoundingBox
+ * placesForTags
+ * resolvePlaceId
+ * tagsForPlace
+
+reflection
+
+ * getMethodInfo
+ * getMethods
+
+tags
+
+ * getClusterPhotos
+ * getClusters
+ * getHotList
+ * getListPhoto
+ * getListUser
+ * getListUserPopular
+ * getListUserRaw
+ * getRelated
+
+urls
+
+ * getGroup
+ * getUserPhotos
+ * getUserProfile
+ * lookupGallery
+ * lookupGroup
+ * lookupUser
+
+util
+
+ * getPhotoUrl
diff --git a/docs/APIs/github/README.md b/docs/APIs/github/README.md
new file mode 100644
index 0000000..97983a6
--- /dev/null
+++ b/docs/APIs/github/README.md
@@ -0,0 +1,47 @@
+github API Reference
+Documentation generated: October 25, 2010 2:35am
+
+user
+
+ * search
+ * show
+ * following
+ * followers
+
+repos
+
+ * watched
+ * search
+ * show
+ * user
+ * collaborators
+ * contributors
+ * watchers
+ * network
+ * languages
+ * tags
+ * branches
+
+issues
+
+ * search
+ * list
+ * show
+ * comments
+
+commits
+
+ * list
+ * file
+ * show
+
+tree
+
+ * show
+ * blob
+ * blobs
+
+gist
+
+ * meta
+ * gists
diff --git a/docs/APIs/plixi/README.md b/docs/APIs/plixi/README.md
new file mode 100644
index 0000000..d50c684
--- /dev/null
+++ b/docs/APIs/plixi/README.md
@@ -0,0 +1,44 @@
+plixi API Reference
+Documentation generated: October 25, 2010 2:35am
+
+user
+
+ * show
+ * comments
+ * friends
+ * favorites
+ * photos
+
+ photo_iterator
+
+ * next
+ * previous
+ * has_favorited
+ * feed
+
+photo
+
+ * show
+ * comments
+ * favorizers
+ * tags
+ * viewers
+ * meta_from_url
+
+photos
+
+ iterator
+
+ * next
+ * previous
+ * by_location
+ * by_venue
+ * list
+ * query_count
+
+leaderboard
+
+ * viewed
+ * commented
+ * voted
+* socialfeed
diff --git a/docs/APIs/reddit/README.md b/docs/APIs/reddit/README.md
new file mode 100644
index 0000000..6e6ceff
--- /dev/null
+++ b/docs/APIs/reddit/README.md
@@ -0,0 +1,32 @@
+reddit API Reference
+Documentation generated: October 25, 2010 2:35am
+
+front_page
+
+ * hot
+ * show_new
+ * controversial
+ * top
+
+subreddit
+
+ * hot
+ * show_new
+ * controversial
+ * top
+* r
+
+post
+
+ * show
+* url
+
+user
+
+ * overview
+ * comments
+ * submitted
+ * liked
+ * disliked
+ * hidden
+* search
diff --git a/docs/APIs/tumblr/README.md b/docs/APIs/tumblr/README.md
new file mode 100644
index 0000000..787a35f
--- /dev/null
+++ b/docs/APIs/tumblr/README.md
@@ -0,0 +1,6 @@
+tumblr API Reference
+Documentation generated: October 25, 2010 2:35am
+
+posts
+
+ * show
diff --git a/docs/APIs/twitpic/README.md b/docs/APIs/twitpic/README.md
new file mode 100644
index 0000000..f9f3a70
--- /dev/null
+++ b/docs/APIs/twitpic/README.md
@@ -0,0 +1,38 @@
+twitpic API Reference
+Documentation generated: October 25, 2010 2:35am
+
+media
+
+ * show
+
+users
+
+ * show
+
+comments
+
+ * show
+
+place
+
+ * show
+
+places
+
+ * show
+
+events
+
+ * show
+
+event
+
+ * show
+
+tags
+
+ * show
+
+util
+
+ * getPhotoUrl
diff --git a/docs/APIs/twitter/README.md b/docs/APIs/twitter/README.md
new file mode 100644
index 0000000..7f78d64
--- /dev/null
+++ b/docs/APIs/twitter/README.md
@@ -0,0 +1,50 @@
+twitter API Reference
+Documentation generated: October 25, 2010 2:35am
+
+statuses
+
+ * public_timeline
+ * user_timeline
+ * show
+ * retweets
+ * friends
+ * followers
+
+users
+
+ * show
+ * suggestions
+
+trends
+
+ * show
+ * current
+ * daily
+ * weekly
+ * available
+
+lists
+
+ * statuses
+
+friendships
+
+ * exists
+ * show
+
+friends
+
+ * ids
+
+followers
+
+ * ids
+
+geo
+
+ * nearby_places
+ * search
+ * similar_places
+ * reverse_geocode
+ * show
+* search
diff --git a/docs/APIs/typepad/README.md b/docs/APIs/typepad/README.md
new file mode 100644
index 0000000..f2aab7a
--- /dev/null
+++ b/docs/APIs/typepad/README.md
@@ -0,0 +1,178 @@
+typepad API Reference
+Documentation generated: October 25, 2010 2:35am
+
+api_keys
+
+ * show
+
+applications
+
+ * show
+
+ badges
+
+ * show
+ * learning
+ * public
+ * external_feed_subscriptions
+ * groups
+
+assets
+
+ * search
+ * show
+ * categories
+ * comment_tree
+ * comments
+ * extended_content
+ * favorites
+ * feedback_status
+ * media
+ * publication_status
+ * reblogs
+ * trending
+
+auth_tokens
+
+ * show
+
+badges
+
+ * show
+
+blogs
+
+ * show
+ * categories
+ * commenting_settings
+
+ comments
+
+ * published
+ * recent
+ * crosspost_accounts
+ * page_assets
+
+ post_assets
+
+ * show
+ * by_category
+ * by_filename
+ * by_month
+
+ published
+
+ * by_category
+ * by_month
+ * recent
+ * recent
+ * post_by_email_settings
+ * stats
+
+client_library_helpers
+
+ * method_mappings
+ * object_types
+
+conversations
+
+ * list
+ * show
+
+domains
+
+ * show
+
+events
+
+ * show
+
+external_feed_subscriptions
+
+ * show
+ * feeds
+
+favorites
+
+ * show
+
+groups
+
+ * show
+ * audio_assets
+ * events
+ * extenal_feed_subscriptions
+ * link_assets
+
+ memberships
+
+ * list
+ * admin
+ * blocked
+ * member
+ * photo_assets
+ * post_assets
+ * video_assets
+
+import_jobs
+
+ * show
+
+relationships
+
+ * show
+ * status
+* request_properties
+
+users
+
+ * show
+
+ badges
+
+ * list
+ * learning
+ * public
+ * blogs
+ * elsewhere_accounts
+
+ events
+
+ * list
+ * by_group
+ * favorites
+
+ memberships
+
+ * list
+ * admin
+ * by_group
+ * member
+
+ notifications
+
+ * list
+ * by_group
+ * profile
+
+ relationships
+
+ * list
+ * by_group
+ * by_user
+
+ follower
+
+ * list
+ * by_group
+
+ following
+
+ * list
+ * by_group
+
+verticals
+
+ * list
+ * show
+ * tags
diff --git a/docs/APIs/wordpress/README.md b/docs/APIs/wordpress/README.md
new file mode 100644
index 0000000..212af91
--- /dev/null
+++ b/docs/APIs/wordpress/README.md
@@ -0,0 +1,36 @@
+wordpress API Reference
+Documentation generated: October 25, 2010 2:35am
+
+posts
+
+ * recent
+
+post
+
+ * show
+
+page
+
+ * show
+ * index
+
+date
+
+ * posts
+ * index
+
+category
+
+ * posts
+ * index
+
+tag
+
+ * posts
+ * index
+
+author
+
+ * posts
+ * index
+* search
diff --git a/docs/APIs/yql/README.md b/docs/APIs/yql/README.md
new file mode 100644
index 0000000..625a43f
--- /dev/null
+++ b/docs/APIs/yql/README.md
@@ -0,0 +1,5 @@
+yql API Reference
+Documentation generated: October 25, 2010 2:35am
+
+* query
+* select
diff --git a/docs/api_def/flickr.xml b/docs/api_def/flickr.xml
deleted file mode 100644
index 57eda88..0000000
--- a/docs/api_def/flickr.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/api_def/github.xml b/docs/api_def/github.xml
deleted file mode 100644
index 189880a..0000000
--- a/docs/api_def/github.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/api_def/plixi.xml b/docs/api_def/plixi.xml
deleted file mode 100644
index ce8b830..0000000
--- a/docs/api_def/plixi.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/api_def/reddit.xml b/docs/api_def/reddit.xml
deleted file mode 100644
index e0fb62b..0000000
--- a/docs/api_def/reddit.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/api_def/tumblr.xml b/docs/api_def/tumblr.xml
deleted file mode 100644
index 77f1495..0000000
--- a/docs/api_def/tumblr.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/docs/api_def/twitpic.xml b/docs/api_def/twitpic.xml
deleted file mode 100644
index e33b4e9..0000000
--- a/docs/api_def/twitpic.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/api_def/twitter.xml b/docs/api_def/twitter.xml
deleted file mode 100644
index 56d65ad..0000000
--- a/docs/api_def/twitter.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/api_def/typepad.xml b/docs/api_def/typepad.xml
deleted file mode 100644
index d8c23e6..0000000
--- a/docs/api_def/typepad.xml
+++ /dev/null
@@ -1,177 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/docs/api_def/wordpress.xml b/docs/api_def/wordpress.xml
deleted file mode 100644
index ef734bd..0000000
--- a/docs/api_def/wordpress.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/scripts/autogen_docs.js b/scripts/autogen_docs.js
index dcbac0b..92d0027 100644
--- a/scripts/autogen_docs.js
+++ b/scripts/autogen_docs.js
@@ -21,7 +21,7 @@ var fs = require('fs'),
jsonp_query: function () { }
},
lib_dir = '../lib/',
- api_def = '../docs/api_def/',
+ apis = '../docs/APIs/',
window = {},
document = {
getElementById: function () { },
@@ -39,7 +39,7 @@ jsonpfu = {
(function () {
var generate = function (file) {
var code = fs.readFileSync(lib_dir + file + '.js', 'utf8'),
- xml;
+ md = "";
try{
eval(code);
@@ -51,10 +51,19 @@ jsonpfu = {
return;
}
- xml = '\n';
- xml += OBJtoXML(libs[file]);
- fs.writeFileSync(api_def + file + '.xml', xml, 'utf8');
+ md += "" + file + " API Reference\n";
+ md += "Documentation generated: " + date('F j, Y g:ia') + "\n";
+ md += OBJtoMarkdown(libs[file]);
+
+ try {
+ fs.statSync(apis + file);
+ } catch (err) {
+ fs.mkdirSync(apis + file, 0775);
+ }
+
+ fs.writeFileSync(apis + file + '/README.md', md, 'utf8');
},
+
OBJtoXML = function (obj, d) {
d = (d) ? d : 0;
var rString = "\n";
@@ -96,6 +105,46 @@ jsonpfu = {
else {
return false;
}
+ return rString;
+ },
+
+ OBJtoMarkdown = function (obj, d) {
+ d = (d) ? d : 0;
+ var rString = "\n";
+ var pad = "";
+ for (var i = 0; i < d; i++) {
+ pad += "\t";
+ }
+ if (typeof obj === "object") {
+ if (obj.constructor.toString().indexOf("Array") !== -1) {
+ for (i = 0; i < obj.length; i++) {
+ rString += pad + "" + obj[i] + "\n";
+ }
+ rString = rString.substr(0, rString.length - 1)
+ }
+ else {
+ for (i in obj) {
+ if (typeof obj[i] === 'function') {
+ rString += pad + '* ' + i + "\n";
+ } else {
+ var val = OBJtoMarkdown(obj[i], d + 1);
+ if (!val) return false;
+ rString += ((rString === "\n") ? "" : "\n") +
+ pad + '' + i + "\n" + val;
+ }
+ }
+ }
+ }
+ else if (typeof obj === "string") {
+ rString = obj;
+ }
+ else if (obj.toString) {
+ rString = obj.toString();
+ }
+ else {
+ return false;
+ }
+
return rString;
};
@@ -111,7 +160,7 @@ jsonpfu = {
file = file_info[0];
try {
- fs.readFileSync(api_def + file + '.xml');
+ fs.readFileSync(apis + file + '/README.md');
console.log("Skipping:\t" + file);
} catch (err) {
console.log("Generating:\t" + file);
@@ -120,3 +169,267 @@ jsonpfu = {
}
});
}());
+
+function date(format, timestamp) {
+ // http://kevin.vanzonneveld.net
+ // + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
+ // + parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html)
+ // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: MeEtc (http://yass.meetcweb.com)
+ // + improved by: Brad Touesnard
+ // + improved by: Tim Wiel
+ // + improved by: Bryan Elliott
+ //
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: David Randall
+ // + input by: Brett Zamir (http://brett-zamir.me)
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: Theriault
+ // + derived from: gettimeofday
+ // + input by: majak
+ // + bugfixed by: majak
+ // + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+ // + input by: Alex
+ // + bugfixed by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: Theriault
+ // + improved by: Brett Zamir (http://brett-zamir.me)
+ // + improved by: Theriault
+ // + improved by: Thomas Beaucourt (http://www.webapp.fr)
+ // + improved by: JT
+ // + improved by: Theriault
+ // + improved by: RafaĆ Kukawski (http://blog.kukawski.pl)
+ // % note 1: Uses global: php_js to store the default timezone
+ // % note 2: Although the function potentially allows timezone info (see notes), it currently does not set
+ // % note 2: per a timezone specified by date_default_timezone_set(). Implementers might use
+ // % note 2: this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST set by that function
+ // % note 2: in order to adjust the dates in this function (or our other date functions!) accordingly
+ // * example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400);
+ // * returns 1: '09:09:40 m is month'
+ // * example 2: date('F j, Y, g:i a', 1062462400);
+ // * returns 2: 'September 2, 2003, 2:26 am'
+ // * example 3: date('Y W o', 1062462400);
+ // * returns 3: '2003 36 2003'
+ // * example 4: x = date('Y m d', (new Date()).getTime()/1000);
+ // * example 4: (x+'').length == 10 // 2009 01 09
+ // * returns 4: true
+ // * example 5: date('W', 1104534000);
+ // * returns 5: '53'
+ // * example 6: date('B t', 1104534000);
+ // * returns 6: '999 31'
+ // * example 7: date('W U', 1293750000.82); // 2010-12-31
+ // * returns 7: '52 1293750000'
+ // * example 8: date('W', 1293836400); // 2011-01-01
+ // * returns 8: '52'
+ // * example 9: date('W Y-m-d', 1293974054); // 2011-01-02
+ // * returns 9: '52 2011-01-02'
+ var that = this,
+ jsdate, f, formatChr = /\\?([a-z])/gi, formatChrCb,
+ // Keep this here (works, but for code commented-out
+ // below for file size reasons)
+ //, tal= [],
+ _pad = function (n, c) {
+ if ((n = n + "").length < c) {
+ return new Array((++c) - n.length).join("0") + n;
+ } else {
+ return n;
+ }
+ },
+ txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
+ "January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December"],
+ txt_ordin = {
+ 1: "st",
+ 2: "nd",
+ 3: "rd",
+ 21: "st",
+ 22: "nd",
+ 23: "rd",
+ 31: "st"
+ };
+ formatChrCb = function (t, s) {
+ return f[t] ? f[t]() : s;
+ };
+ f = {
+ // Day
+ d: function () { // Day of month w/leading 0; 01..31
+ return _pad(f.j(), 2);
+ },
+ D: function () { // Shorthand day name; Mon...Sun
+ return f.l().slice(0, 3);
+ },
+ j: function () { // Day of month; 1..31
+ return jsdate.getDate();
+ },
+ l: function () { // Full day name; Monday...Sunday
+ return txt_words[f.w()] + 'day';
+ },
+ N: function () { // ISO-8601 day of week; 1[Mon]..7[Sun]
+ return f.w() || 7;
+ },
+ S: function () { // Ordinal suffix for day of month; st, nd, rd, th
+ return txt_ordin[f.j()] || 'th';
+ },
+ w: function () { // Day of week; 0[Sun]..6[Sat]
+ return jsdate.getDay();
+ },
+ z: function () { // Day of year; 0..365
+ var a = new Date(f.Y(), f.n() - 1, f.j()),
+ b = new Date(f.Y(), 0, 1);
+ return Math.round((a - b) / 864e5) + 1;
+ },
+
+ // Week
+ W: function () { // ISO-8601 week number
+ var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
+ b = new Date(a.getFullYear(), 0, 4);
+ return 1 + Math.round((a - b) / 864e5 / 7);
+ },
+
+ // Month
+ F: function () { // Full month name; January...December
+ return txt_words[6 + f.n()];
+ },
+ m: function () { // Month w/leading 0; 01...12
+ return _pad(f.n(), 2);
+ },
+ M: function () { // Shorthand month name; Jan...Dec
+ return f.F().slice(0, 3);
+ },
+ n: function () { // Month; 1...12
+ return jsdate.getMonth() + 1;
+ },
+ t: function () { // Days in month; 28...31
+ return (new Date(f.Y(), f.n(), 0)).getDate();
+ },
+
+ // Year
+ L: function () { // Is leap year?; 0 or 1
+ return new Date(f.Y(), 1, 29).getMonth() === 1 | 0;
+ },
+ o: function () { // ISO-8601 year
+ var n = f.n(), W = f.W(), Y = f.Y();
+ return Y + (n === 12 && W < 9 ? -1 : n === 1 && W > 9);
+ },
+ Y: function () { // Full year; e.g. 1980...2010
+ return jsdate.getFullYear();
+ },
+ y: function () { // Last two digits of year; 00...99
+ return (f.Y() + "").slice(-2);
+ },
+
+ // Time
+ a: function () { // am or pm
+ return jsdate.getHours() > 11 ? "pm" : "am";
+ },
+ A: function () { // AM or PM
+ return f.a().toUpperCase();
+ },
+ B: function () { // Swatch Internet time; 000..999
+ var H = jsdate.getUTCHours() * 36e2, // Hours
+ i = jsdate.getUTCMinutes() * 60, // Minutes
+ s = jsdate.getUTCSeconds(); // Seconds
+ return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
+ },
+ g: function () { // 12-Hours; 1..12
+ return f.G() % 12 || 12;
+ },
+ G: function () { // 24-Hours; 0..23
+ return jsdate.getHours();
+ },
+ h: function () { // 12-Hours w/leading 0; 01..12
+ return _pad(f.g(), 2);
+ },
+ H: function () { // 24-Hours w/leading 0; 00..23
+ return _pad(f.G(), 2);
+ },
+ i: function () { // Minutes w/leading 0; 00..59
+ return _pad(jsdate.getMinutes(), 2);
+ },
+ s: function () { // Seconds w/leading 0; 00..59
+ return _pad(jsdate.getSeconds(), 2);
+ },
+ u: function () { // Microseconds; 000000-999000
+ return _pad(jsdate.getMilliseconds() * 1000, 6);
+ },
+
+ // Timezone
+ e: function () { // Timezone identifier; e.g. Atlantic/Azores, ...
+// The following works, but requires inclusion of the very large
+// timezone_abbreviations_list() function.
+/* return this.date_default_timezone_get();
+*/
+ throw 'Not supported (see source code of date() for timezone on how to add support)';
+ },
+ I: function () { // DST observed?; 0 or 1
+ // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
+ // If they are not equal, then DST is observed.
+ var a = new Date(f.Y(), 0), // Jan 1
+ c = Date.UTC(f.Y(), 0), // Jan 1 UTC
+ b = new Date(f.Y(), 6), // Jul 1
+ d = Date.UTC(f.Y(), 6); // Jul 1 UTC
+ return 0 + ((a - c) !== (b - d));
+ },
+ O: function () { // Difference to GMT in hour format; e.g. +0200
+ var a = jsdate.getTimezoneOffset();
+ return (a > 0 ? "-" : "+") + _pad(Math.abs(a / 60 * 100), 4);
+ },
+ P: function () { // Difference to GMT w/colon; e.g. +02:00
+ var O = f.O();
+ return (O.substr(0, 3) + ":" + O.substr(3, 2));
+ },
+ T: function () { // Timezone abbreviation; e.g. EST, MDT, ...
+// The following works, but requires inclusion of the very
+// large timezone_abbreviations_list() function.
+/* var abbr = '', i = 0, os = 0, default = 0;
+ if (!tal.length) {
+ tal = that.timezone_abbreviations_list();
+ }
+ if (that.php_js && that.php_js.default_timezone) {
+ default = that.php_js.default_timezone;
+ for (abbr in tal) {
+ for (i=0; i < tal[abbr].length; i++) {
+ if (tal[abbr][i].timezone_id === default) {
+ return abbr.toUpperCase();
+ }
+ }
+ }
+ }
+ for (abbr in tal) {
+ for (i = 0; i < tal[abbr].length; i++) {
+ os = -jsdate.getTimezoneOffset() * 60;
+ if (tal[abbr][i].offset === os) {
+ return abbr.toUpperCase();
+ }
+ }
+ }
+*/
+ return 'UTC';
+ },
+ Z: function () { // Timezone offset in seconds (-43200...50400)
+ return -jsdate.getTimezoneOffset() * 60;
+ },
+
+ // Full Date/Time
+ c: function () { // ISO-8601 date.
+ return 'Y-m-d\\Th:i:sP'.replace(formatChr, formatChrCb);
+ },
+ r: function () { // RFC 2822
+ return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
+ },
+ U: function () { // Seconds since UNIX epoch
+ return jsdate.getTime() / 1000 | 0;
+ }
+ };
+ this.date = function (format, timestamp) {
+ that = this;
+ jsdate = (
+ (typeof timestamp === 'undefined') ? new Date() : // Not provided
+ (timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
+ new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
+ );
+ return format.replace(formatChr, formatChrCb);
+ };
+ return this.date(format, timestamp);
+}