what time is it now

  • /*
     * @title what time is it now
     * @description iso8601 timestamp on prompt
     * @include http://*
     * @license MIT License
     * @require 
     */
    
    (function(){
      function trim(num,l){
        if(num<0){
          num=-(num);
        }
        if(typeof(num)!='string'){
          num=''+num;
        }
        var s=l-num.length;
        while(s>0){
          num='0'+num;
          --s;
        }
        return num;
      }
      ;
      var d=new Date,YYYY=trim(d.getFullYear(),4),MM_1=trim(d.getMonth()+1,2),DD=trim(d.getDate(),2),T='T',HH=trim(d.getHours(),2),MM_2=trim(d.getMinutes(),2),SS=trim(d.getSeconds(),2),offset=d.getTimezoneOffset(),plus='-',ZZ_1=trim(offset/60,2),ZZ_2=trim(offset%60,2),ISO;
      if(offset<=0){
        plus='+';
        offset=-(offset);
      }
      ;
      ISO=YYYY+'-'+MM_1+'-'+DD+T+HH+':'+MM_2+':'+SS+plus+ZZ_1+':'+ZZ_2;
      if(!prompt('what time is it now',ISO)){
        arguments.callee();
      }
    }
    )()
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/11/11 08:54:30 - 2010-11-11
  2. 2010/11/11 08:53:12 - 2010-11-11
  3. 2010/05/27 22:37:29 - 2010-05-27
  4. 2010/05/16 00:48:49 - 2010-05-16
  5. 2010/05/15 23:35:27 - 2010-05-15