129129(datetime--define-error 'datetime-unsupported-timezone " Timezones are currently not supported" )
130130
131131
132- (defconst datetime--directory (file-name-directory (or load-file-name (buffer-file-name ))))
132+ ; ; Defining the three extmap database variables like this so that values _are_ replaced if these
133+ ; ; variable declaration is reevaluated (rather, the whole buffer). Otherwise e.g. reinstalling
134+ ; ; `datetime' package could leave unusable extmap objects referring to removed files.
135+ ; ;
136+ ; ; FIXME: Would be nice to add ERT test(s).
133137
134138; ; Extracted from Java using `dev/HarvestData.java' . All patterns are
135139; ; obviously of `java' type.
153157; ; - all patterns have the following fallbacks: `:short' defaults to
154158; ; `:medium' , `:long' defaults to `:medium' , `:full' defaults to
155159; ; `:long' .
156- (defvar datetime--locale-extmap (extmap-init ( expand-file-name " locale-data.extmap " datetime--directory) :auto-reload t ) )
160+ (defvar datetime--locale-extmap nil )
157161
158162; ; Extracted from Java using `dev/HarvestData.java' .
159- (defvar datetime--timezone-extmap (extmap-init ( expand-file-name " timezone-data.extmap " datetime--directory) :weak-data t :auto-reload t ) )
163+ (defvar datetime--timezone-extmap nil )
160164
161165; ; Extracted from Java using `dev/HarvestData.java' .
162166; ;
171175; ; English locale;
172176; ; [ABBREVIATED FULL] -- no special for DST;
173177; ; [ABBREVIATED-STD ABBREVIATED-DST FULL-STD FULL-DST].
174- (defvar datetime--timezone-name-extmap (extmap-init (expand-file-name " timezone-name-data.extmap" datetime--directory) :weak-data t :auto-reload t ))
178+ (defvar datetime--timezone-name-extmap nil )
179+
180+ (dolist (entry
181+ '((datetime--locale-extmap " locale-data.extmap" :auto-reload t )
182+ (datetime--timezone-extmap " timezone-data.extmap" :weak-data t :auto-reload t )
183+ (datetime--timezone-name-extmap " timezone-name-data.extmap" :weak-data t :auto-reload t )))
184+ (let ((directory (file-name-directory (or load-file-name (buffer-file-name ))))
185+ (variable (nth 0 entry))
186+ (filename (nth 1 entry))
187+ (options (nthcdr 2 entry)))
188+ (unless (ignore-errors (file-equal-p (file-name-directory (cdr (assq 'filename (extmap-statistics (symbol-value variable)))))
189+ directory))
190+ (set variable (apply #'extmap-init (expand-file-name filename directory) options)))))
175191
176192(defvar datetime--pattern-parsers '((parsed . (lambda (pattern options ) pattern))
177193 (java . datetime--parse-java-pattern)))
@@ -223,7 +239,6 @@ You can see the list of locales supported by the library by
223239evaluating this form:
224240
225241 (prin1-to-string (sort (datetime-list-locales t) #\\= 'string<))"
226- :group 'datetime
227242 ; ; The only minor problem is the type won't be rebuilt if `datetime--locale-extmap' is
228243 ; ; autoreloaded, but oh well.
229244 :type `(choice (const nil ) ,@(mapcar (lambda (locale ) `(const , locale )) (datetime-list-locales t ))))
@@ -237,7 +252,6 @@ You can see the list of supported timezones by evaluating this
237252form:
238253
239254 (prin1-to-string (sort (datetime-list-timezones) #\\= 'string<))"
240- :group 'datetime
241255 :type `(choice (const nil ) ,@(mapcar (lambda (locale ) `(const , locale )) (datetime-list-timezones))))
242256
243257
@@ -1826,7 +1840,7 @@ OPTIONS are passed to `datetime-recode-pattern'. Currently no
18261840options can affect result of this function."
18271841 (datetime--pattern-includes-p type pattern options second-fractional))
18281842
1829- (define-obsolete-function-alias 'datetime-pattern-includes-millisecond-p 'datetime-pattern-includes-second-fractionals-p " 0.6.1" )
1843+ (define-obsolete-function-alias 'datetime-pattern-includes-millisecond-p # 'datetime-pattern-includes-second-fractionals-p " 0.6.1" )
18301844
18311845(defun datetime-pattern-num-second-fractionals (type pattern &rest options )
18321846 " Determine number of second fractional digits in the PATTERN.
0 commit comments