From 73997b8d03eba1d4ee6c8fedd5b27817afa5e9fb Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 8 Jun 2011 10:17:02 -0700 Subject: [PATCH] %b %B --- 4chan_x.user.js | 11 ++++++++++- script.coffee | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 8365c7699..1b9197717 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -958,7 +958,7 @@ var arr, checked, description, dialog, hiddenNum, hiddenThreads, html, input, key, li, main, obj, ul, _i, _len, _ref, _ref2; hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {}); hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length; - html = "
Options X


Sauce flavors
Time Formatting
Donate
support throd | github | uso
"; + html = "
Options X


Sauce flavors
Time Formatting
Donate
support throd | github | uso
"; dialog = ui.dialog('options', { top: '25%', left: '25%' @@ -1701,6 +1701,8 @@ code = $.config('time').replace(/%([A-Za-z])/g, function(s, c) { switch (c) { case 'a': + case 'b': + case 'B': case 'd': case 'H': case 'I': @@ -1717,6 +1719,7 @@ }); return time.funk = Function('time', "return '" + code + "'"); }, + month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], zeroPad: function(n) { if (n < 10) { return '0' + n; @@ -1727,6 +1730,12 @@ a: function() { return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][this.date.getDay()]; }, + b: function() { + return this.month[this.date.getMonth()].slice(0, 3); + }, + B: function() { + return this.month[this.date.getMonth()]; + }, d: function() { return this.zeroPad(this.date.getDate()); }, diff --git a/script.coffee b/script.coffee index a3954250d..7673070bd 100644 --- a/script.coffee +++ b/script.coffee @@ -744,6 +744,8 @@ options = SpecifierDescriptionValues/Example %aweekday, abbreviatedFri + %bmonth, abbreviatedJun + %Bmonth, full lengthJune %dday of the month, zero padded03 %Hhour (24 hour clock) zero padded13 %Ihour (12 hour clock) zero padded02 @@ -1358,10 +1360,23 @@ time = foo: -> code = $.config('time').replace /%([A-Za-z])/g, (s, c) -> switch c - when 'a', 'd', 'H', 'I', 'm', 'M', 'p', 'P', 'y' then "' + time.#{c}() + '" + when 'a', 'b', 'B', 'd', 'H', 'I', 'm', 'M', 'p', 'P', 'y' then "' + time.#{c}() + '" else s time.funk = Function 'time', "return '#{code}'" - + month: [ + 'January' + 'February' + 'March' + 'April' + 'May' + 'June' + 'July' + 'August' + 'September' + 'October' + 'November' + 'December' + ] zeroPad: (n) -> if n < 10 then '0' + n else n a: -> [ 'Sun' @@ -1372,6 +1387,8 @@ time = 'Fri' 'Sat' ][@date.getDay()] + b: -> @month[@date.getMonth()][...3] + B: -> @month[@date.getMonth()] d: -> @zeroPad @date.getDate() H: -> @zeroPad @date.getHours() I: -> @zeroPad @date.getHours() % 12 or 12