Comparing version 0.0.20 to 0.0.21
@@ -54,3 +54,3 @@ /** | ||
// W: ISO 8601 week number of the year, weeks starting on Monday | ||
W: function(now){ return "?"; }, | ||
W: function(now){ return iso8601week(now); }, | ||
@@ -65,3 +65,3 @@ F: function(now){ return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][now.getMonth()]; }, | ||
// o: ISO 8601 year number | ||
o: function(now){ return "?"; }, | ||
o: function(now){ return pad4(iso8601year(now)); }, | ||
Y: function(now){ return pad4(now.getFullYear()); }, | ||
@@ -97,2 +97,26 @@ y: function(now){ return pad4(now.getFullYear() % 100); }, | ||
function iso8601week( now ) { | ||
/* | ||
* ISO-8601 week number of year, weeks starting on Monday | ||
* AR: note that Tue, Jan 1st would be week number 53 (of previous year) | ||
*/ | ||
var offs = weekdayOffset(now); | ||
// offs.week is 0..6 day in week offset | ||
// offs.year is 0..356 day in year offset | ||
// offs.year % 7 is number of 7-day groups since Jan 1st | ||
// FIXME: writeme | ||
return '??'; | ||
} | ||
function iso8601year( now ) { | ||
/* | ||
* ISO-8601 year number. This has the same value as Y, except that if the | ||
* ISO week number (W) belongs to the previous or next year, that year is | ||
* used instead. | ||
* AR: note that Tue, Jan 1st would be last year, new year starts next Monday. | ||
*/ | ||
// FIXME: writeme | ||
return '????'; | ||
} | ||
function hour1to12( now ) { | ||
@@ -167,3 +191,3 @@ var hour = now.getHours() % 12; | ||
var date = now.getDate(); | ||
if (date > 10 && date < 20) return 'th'; | ||
if (date % 100 > 10 && date % 100 < 20) return 'th'; | ||
else return ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th'][date % 10]; | ||
@@ -170,0 +194,0 @@ } |
{ | ||
"name": "arlib", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "Andras' Utility Functions", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -65,3 +65,4 @@ # arlib | ||
See php's [date](http://php.net/manual/en/function.date.php) for the list of | ||
supported conversions. Of them, W and o are not implemented. | ||
supported conversions. Of the conversions as of 2014-09-15 (php 5.1.0), | ||
W and o are not yet implemented. | ||
@@ -119,2 +120,6 @@ var phpdate = require('arlib/phpdate'); | ||
var params = [1, 2, 3]; | ||
var queryString = http_build_query(params, {numeric_prefix: 'idx'}); | ||
// => "idx0=1&idx1=2&idx2=3" | ||
options: | ||
@@ -121,0 +126,0 @@ |
57673
1305
131