aboutsummaryrefslogtreecommitdiffstats
path: root/clock.js
diff options
context:
space:
mode:
authoranekos2008-11-28 15:38:56 +0000
committeranekos2008-11-28 15:38:56 +0000
commitb38396a8f8aa88915b38ab747b265b089ab96133 (patch)
treec397e7d67d1839db260b8b67ac48cc91643bcaa8 /clock.js
parentb3f37390bb8bbdcd89627608c379a055291e6ea6 (diff)
downloadvimperator-plugins-b38396a8f8aa88915b38ab747b265b089ab96133.tar.bz2
added "%a"
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@25288 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'clock.js')
-rw-r--r--clock.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/clock.js b/clock.js
index c25b504..759513a 100644
--- a/clock.js
+++ b/clock.js
@@ -4,7 +4,7 @@
* @description clock.
* @description-ja とけい。
* @author janus_wel <janus_wel@fb3.so-net.ne.jp>
- * @version 0.11
+ * @version 0.12
* @minversion 2.0pre
* @maxversion 2.0pre
* ==/VimperatorPlugin==
@@ -20,6 +20,7 @@
* %t: time hh:mm
* %d: day MM/DD
* %y: year YYYY
+ * %a: A abbreviation for the day of the week.
* clock_position: id of element that is marker of insert position.
* default is 'liberator-commandline-command' ( after commandline )
* clock_after: boolean that show insert after of the element
@@ -90,6 +91,9 @@ Clock.prototype = {
t: function (label) {
return setInterval(function () label.setAttribute('value', time()), 100);
},
+ a: function (label) {
+ return setInterval(function () label.setAttribute('value', wday()), 60 * 1000);
+ },
d: function (label) {
return setInterval(function () label.setAttribute('value', day()), 60 * 1000);
},
@@ -109,6 +113,16 @@ Clock.prototype = {
intervalId: id,
};
},
+ a: function (self) {
+ let l = self._master.cloneNode(false);
+ l.setAttribute('id', self._constants.prefix + 'wday');
+ l.setAttribute('value', weekDay());
+ let id = self._constants.driver.a(l);
+ return {
+ node: l,
+ intervalId: id,
+ };
+ },
d: function (self) {
let l = self._master.cloneNode(false);
l.setAttribute('id', self._constants.prefix + 'day');
@@ -236,6 +250,12 @@ function time() {
if (min.length < 2) min = '0' + min;
return hour + (now.getMilliseconds() < 400 ? ' ' : ':') + min;
}
+function weekDay() {
+ const wdays = 'sun mon tue wed thu fri sat'.split(/%s/);
+ let now = new Date();
+ return now.toLocaleFormat ? now.toLocaleFormat('%a')
+ : wdays[now.getDay()];
+}
function day() {
let now = new Date();
let date = now.getDate().toString(10);