Changeset 14840
- Timestamp:
- 11/09/15 10:59:10 (7 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Autoload.java
r14493 r14840 520 520 autoload(PACKAGE_EXT, "gc", "gc", true); 521 521 autoload(PACKAGE_EXT, "get-floating-point-modes", "FloatFunctions", true); 522 autoload(PACKAGE_EXT, "get-time-zone", "Time", true); 522 523 autoload(PACKAGE_EXT, "make-slime-input-stream", "SlimeInputStream", true); 523 524 autoload(PACKAGE_EXT, "make-slime-output-stream", "SlimeOutputStream", true); -
trunk/abcl/src/org/armedbear/lisp/Time.java
r12431 r14840 112 112 113 113 // ### default-time-zone => offset daylight-p 114 private static final Primitive DEFAULT_TIME_ZONE = 115 new Primitive("default-time-zone", PACKAGE_SYS, false) 114 public static final Primitive DEFAULT_TIME_ZONE = new pf_default_time_zone(); 115 @DocString(name="default-time-zone", 116 args="", 117 returns="offset daylight-p", 118 doc="Returns the OFFSET of the default time zone for this instance of the implementation, and as a second value the state of the DAYLIGHT-P predicate.") 119 public static final class pf_default_time_zone extends Primitive { 120 pf_default_time_zone() { 121 super("default-time-zone", PACKAGE_SYS, true); 122 } 123 public LispObject execute() 116 124 { 117 @Override 118 public LispObject execute() 119 { 120 TimeZone tz = TimeZone.getDefault(); 121 //int offset = tz.getOffset(System.currentTimeMillis()); 122 // Classpath hasn't implemented TimeZone.getOffset(long). 123 int rawOffset = tz.getRawOffset(); 124 final boolean inDaylightTime = 125 tz.inDaylightTime(new Date(System.currentTimeMillis())); 126 if (inDaylightTime) 127 rawOffset += tz.getDSTSavings(); 128 // "Time zone values increase with motion to the west..." 129 // Convert milliseconds to hours. 130 return LispThread.currentThread().setValues( 131 Fixnum.getInstance(- rawOffset).divideBy(Fixnum.getInstance(3600000)), 132 inDaylightTime ? T : NIL); 133 } 134 }; 125 return GET_TIME_ZONE.execute(LispInteger.getInstance(System.currentTimeMillis())); 126 } 127 }; 128 129 public static final Primitive GET_TIME_ZONE = new pf_get_time_zone(); 130 @DocString(name="get-time-zone", 131 args="time-in-millis", 132 returns="timezone", 133 doc="Return the timezone for TIME-IN-MILLIS via the Daylight assumptions that were in place at its occurance. i.e. implement 'time of the time semantics'." ) 134 public static final class pf_get_time_zone extends Primitive { 135 pf_get_time_zone() { 136 super("get-time-zone", PACKAGE_EXT, true, ""); 137 } 138 139 public LispObject execute(LispObject unixTimeMillis) { 140 // should be a reference to a singleton for the lifetime of an ABCL process 141 TimeZone tz = TimeZone.getDefault(); 142 // int offset = tz.getOffset(System.currentTimeMillis()); 143 // Classpath hasn't implemented TimeZone.getOffset(long). 144 int rawOffset = tz.getRawOffset(); 145 final boolean inDaylightTime = tz.inDaylightTime(new Date(unixTimeMillis.longValue())); 146 if (inDaylightTime) 147 rawOffset += tz.getDSTSavings(); 148 // "Time zone values increase with motion to the west..." 149 // Convert milliseconds to hours. 150 return LispThread.currentThread() 151 .setValues(Fixnum 152 .getInstance(- rawOffset).divideBy(Fixnum.getInstance(3600000)), 153 inDaylightTime ? T : NIL); 154 } 155 }; 135 156 } -
trunk/abcl/src/org/armedbear/lisp/time.lisp
r11391 r14840 43 43 (defconstant weekday-november-17-1858 2) 44 44 45 46 45 47 ;;; decode-universal-time universal-time &optional time-zone 46 48 ;;; => second minute hour date month year day daylight-p zone … … 54 56 (setf seconds-west (* time-zone 3600) 55 57 daylight nil) 56 (multiple-value-bind (time-zone daylight-p) ( default-time-zone)58 (multiple-value-bind (time-zone daylight-p) (ext:get-time-zone universal-time) 57 59 (setf seconds-west (* time-zone 3600) 58 60 daylight daylight-p))) … … 128 130 (hours (+ hour (* days 24)))) 129 131 (cond (time-zone 130 (+ second (* (+ minute (* (+ hours time-zone) 60)) 60))) 132 (let* ((tz-guess (get-time-zone (* hours 3600))) 133 (guess (+ second (* 60 (+ minute (* 60 (+ hours tz-guess)))))) 134 (tz (get-time-zone guess))) 135 (+ guess (* 3600 (- tz tz-guess))))) 131 136 ((> year 2037) 132 137 (labels ((leap-year-p (year) … … 144 149 (t 145 150 (+ second (* (+ minute (* (+ hours (default-time-zone)) 60)) 60)))))) 151 152 #| 153 (intern "GET-TIME-ZONE" (find-package :ext)) 154 (define-symbol-macro EXT:GET-TIME-ZONE 155 `(get-time-zone)) 156 (export (intern "GET-TIME-ZONE" (find-package :ext))) 157 #|
Note: See TracChangeset
for help on using the changeset viewer.