Changeset 8607 for lang/gauche

Show
Ignore:
Timestamp:
04/01/08 20:59:52 (5 years ago)
Author:
kiyoka
Message:

Supported ##(timestamp utc) and #(since utc) command.
Supported timezone of RecentPages's date.

Location:
lang/gauche/oldtype/trunk
Files:
1 added
6 modified

Legend:

Unmodified
Added
Removed
  • lang/gauche/oldtype/trunk/Kahua/oldtype/Makefile

    r7811 r8607  
    3636 
    3737TEST_DIR    = $(PWD) 
    38 SCRIPTFILES = $(package)/$(package).kahua $(package)/version.kahua $(package)/util.kahua $(package)/format.scm $(package)/kahualib.scm $(package)/parse.scm $(package)/util.scm 
     38SCRIPTFILES = $(package)/$(package).kahua $(package)/version.kahua $(package)/util.kahua $(package)/format.scm $(package)/kahualib.scm $(package)/parse.scm $(package)/util.scm $(package)/pasttime.scm 
    3939STATICFILES = $(package)/$(package).css $(package)/staticimg/*.png $(package)/*.el $(package)/import/*.js  $(package)/$(package).js 
    4040 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/oldtype.kahua

    r8254 r8607  
    1111(use oldtype.util) 
    1212(use oldtype.kahualib) 
     13(use oldtype.pasttime) 
    1314(use srfi-1) 
     15(use srfi-19) 
    1416(load "oldtype/version.kahua") 
    1517(load "oldtype/util.kahua") 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/util.kahua

    r8091 r8607  
    295295           (p/ "!!Error : No argument ##(amazon URL) command"))) 
    296296       
     297      ;; timestamp 
     298      ((timestamp) 
     299       (if (< 0 len) 
     300           (let* ((_utc    (car arg)) 
     301                  (d (time-utc->date 
     302                      (seconds->time 
     303                       (string->number 
     304                        _utc))))) 
     305             (text/ (string-append (date->string d "~Y-~m-~d ~I:~M ~p (~z)")))) 
     306           (p/ "!!Error : No argument ##(timestamp UTC) command"))) 
     307 
     308      ;; timestamp 
     309      ((since) 
     310       (if (< 0 len) 
     311           (let1 _utc (car arg) 
     312                 (text/  
     313                  (format "(~a ago)" 
     314                          (string-append 
     315                           (how-long-since  
     316                            (string->number 
     317                             _utc)))))) 
     318           (p/ "!!Error : No argument ##(since UTC) command"))) 
     319 
    297320      ;; download link oldtype-mode.el source code 
    298321      ((download-el) 
     
    301324      (else 
    302325       `(p/ ,(format "!!Error : no such macro \"~a\"!!" command)))))) 
     326 
     327 
     328(define (oldtype:timeago seconds) 
     329  (format "~d" (/ seconds 60))) 
    303330 
    304331 
     
    346373         (filter (lambda (x) (= 1 (modulo (car x) 2)))  alist)))) 
    347374 
    348 (define (oldtype:get-fqdn) 
    349   (assq-ref (oldtype:kahua-app-args) 'fqdn)) 
     375(define (oldtype:get-arguments sym) 
     376  (assq-ref (oldtype:kahua-app-args) sym)) 
    350377 
    351378(define (oldtype:hatena-bookmarks wikiname) 
     
    354381                 (oldtype:gen-page-path wikiname)) 
    355382        (node-set/ 
    356          (a/ (@/ (href (string-append "http://b.hatena.ne.jp/entry/http://" (oldtype:get-fqdn) path))) 
     383         (a/ (@/ (href (string-append "http://b.hatena.ne.jp/entry/http://" (oldtype:get-arguments 'fqdn) path))) 
    357384             (img/ (@/ (src "http://d.hatena.ne.jp/images/b_entry_de.gif")))) 
    358          (img/ (@/ (src (string-append "http://b.hatena.ne.jp/entry/image/http://" (oldtype:get-fqdn) path))))))) 
     385         (img/ (@/ (src (string-append "http://b.hatena.ne.jp/entry/image/http://" (oldtype:get-arguments 'fqdn) path))))))) 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/util.scm

    r8342 r8607  
    108108;;   "2007-09-25T12:54:09.955196Z" 
    109109;; result: 
    110 ;;   ((nanosecond . 0) (second . 9) (minute . 54) (hour . 12) (day . 25) (month . 9) (year . 2007) (zone-offset . 0)) 
     110;;   ((nanosecond . 0) (second . 9) (minute . 54) (hour . 12) (day . 25) (month . 9) (year . 2007) (zone-offset . 0) (utc . 1190724849)) 
     111;;    
    111112(define (oldtype:date-string->date-alist str) 
    112113  (let* ((splitted (map string->number (string-split str #/[TZ.\-:]/))) 
     
    129130      (month       . ,(date-month date-object)) 
    130131      (year        . ,(date-year date-object)) 
    131       (zone-offset . ,(date-zone-offset date-object))))) 
     132      (zone-offset . ,(date-zone-offset date-object)) 
     133      (utc         . ,(time->seconds (date->time-utc date-object)))))) 
     134 
    132135 
    133136;;================================================= 
    134137;; parse svn log 
    135138;; 
    136  
    137139;; 
    138140;; result format: 
     
    218220(define (oldtype:parse-svninfo port) 
    219221  (define (date-string-as-current-locale str) 
    220     (date->string (string->date str "~Y-~m-~dT~H:~M:~S") 
    221                   "~1 ~3 (UTC)")) 
     222    (let* ((date-str (string-append (car (string-split str ".")) " +0000")) 
     223           (utc      (date->time-utc (string->date date-str "~Y-~m-~dT~H:~M:~S ~z")))) 
     224      (date->string (time-utc->date utc) 
     225                    "~Y-~m-~d ~I:~M ~p (~z)"))) 
     226  (define (utc-as-current-locale str) 
     227    (number->string 
     228     (time->seconds 
     229      (date->time-utc 
     230       (string->date  
     231        (string-append (car (string-split str ".")) " +0000") 
     232        "~Y-~m-~dT~H:~M:~S ~z"))))) 
    222233  (let1 sxml 
    223234        (ssax:xml->sxml port '()) 
     
    233244             (commit_date        . ,(date-string-as-current-locale  
    234245                                     (sixth x))) 
     246             (commit_utc         . ,(utc-as-current-locale  
     247                                     (sixth x))) 
    235248             )) 
    236249         (zip 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/plugins/oldtype.scm

    r7811 r8607  
    1414(allow-module oldtype.util) 
    1515(allow-module oldtype.kahualib) 
     16(allow-module oldtype.pasttime) 
    1617(allow-module rfc.uri) 
  • lang/gauche/oldtype/trunk/bin/ot_RecentChanges

    r8342 r8607  
    1818      eval ${line} 
    1919      name=`basename ${name} .ot` 
    20       echo "- CHANGED ${commit_date}: [[${name}]] by ([[${commit_author}]])" 
     20      echo "- ##(timestamp ${commit_utc}) ##(since ${commit_utc}): [[${name}]] by ([[${commit_author}]])" 
    2121  fi 
    2222done | sort -r | head -${DISPLAY_LINES} > ${OT_EDITHOME}/edit/!RecentChanges.ot.tmp