Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -0,0 +1,40 @@
(defun fix-time-string (calendar-string)
"If CALENDAR-STRING has no space between time and am/a.m./pm/p.m., add a space.
Return string with space between time and am/a.m./pm/p.m."
(replace-regexp-in-string "\\([[:digit:]]\\)\\([ap]\\)" "\\1 \\2" calendar-string))
(defun is-pm (calendar-string)
"Test if CALENDAR-STRING has PM/pm/P.M/p.m in it."
(string-match-p "[Pp][.]?[Mm]" calendar-string))
(defun is-hour-1-to-11 (a-calendar-list)
"Test if hour in A-CALENDAR-LIST is between 1 and 11."
(let ((hour-value))
(setq hour-value (nth 2 a-calendar-list))
(and (>= hour-value 1) (<= hour-value 11))))
(defun adjust-if-pm (time-as-string)
"If TIME-AS-STRING includes pm/PM, and hour is 1 to 11, add 12 hours.
Return CALENDAR-LIST modified if date is pm and hour is 1-11; otherwise
return CALENDAR-LIST of original TIME-AS-STRING."
(let ((calendar-list))
(setq calendar-list (parse-time-string time-as-string))
(if (and (is-pm time-as-string) (is-hour-1-to-11 calendar-list))
(decoded-time-add calendar-list (make-decoded-time :hour 12))
calendar-list)))
(defun add-hours (calendar-list number-of-hours)
"Add NUMBER-OF-HOURS to CALENDAR-LIST."
(decoded-time-add calendar-list (make-decoded-time :hour number-of-hours)))
(defun calc-future-time (string-calendar-date number-of-hours-in-future)
"Calculate future time by adding NUMBER-OF-HOURS-IN-FUTURE to STRING-CALENDAR-DATE ."
(let ((fixed-calendar-string)
(24-hour-calendar-list)
(calendar-list-future-time)
(coded-future-time))
(setq fixed-calendar-string (fix-time-string string-calendar-date))
(setq 24-hour-calendar-list (adjust-if-pm fixed-calendar-string))
(setq calendar-list-future-time (add-hours 24-hour-calendar-list number-of-hours-in-future))
(setq coded-future-time (encode-time calendar-list-future-time))
(format-time-string "%B %e %Y %R %p %Z" coded-future-time)))

View file

@ -0,0 +1,41 @@
(defun fix-time-string (calendar-string)
"If CALENDAR-STRING has no space between time and a.m./p.m., add a space."
(replace-regexp-in-string "\\([[:digit:]]\\)\\([ap]\\)" "\\1 \\2" calendar-string))
(defun is-pm (calendar-string)
"Test if CALENDAR-STRING has PM/pm in it."
(string-match-p "[Pp][Mm]" time-as-string))
(defun is-hour-1-to-11 (a-calendar-list)
"Test if hour in A-CALENDAR-LIST is between 1 and 11."
(let ((hour-value))
(setq hour-value (nth 2 a-calendar-list))
(and (>= hour-value 1) (<= hour-value 11))))
(defun adjust-if-pm (time-as-string)
"If TIME-AS-STRING includes pm/PM, and hour is 1 to 11, add 12 hours.
Return time as integer of seconds past the epoch."
(let ((calendar-list)
(temp-time-stamp)
(time-stamp-as-integer))
(setq calendar-list (parse-time-string time-as-string))
(setq temp-time-stamp (encode-time calendar-list))
(setq time-stamp-as-integer (time-convert temp-time-stamp 'integer))
(if (and (is-pm time-as-string) (is-hour-1-to-11 calendar-list))
(+ time-stamp-as-integer (* 12 60 60)) ; return time + 12 hours, so that hour is 13-23
time-stamp-as-integer))) ; return time unchanged, leaving hour 0-12
(defun add-seconds (start-time-stamp-integer number-of-seconds)
"Add NUMBER-OF-HOURS to START-TIME-STAMP-INTEGER."
(+ start-time-stamp-integer number-of-seconds))
(defun calc-future-time (string-calendar-date number-of-seconds-in-future)
"Calculate future time by adding NUMBER-OF-SECONDS-IN-FUTURE to STRING-CALENDAR-DATE ."
(let ((fixed-calendar-string)
(time-stamp-as-integer)
(coded-current-time)
(future-time-as-integer))
(setq fixed-calendar-string (fix-time-string string-calendar-date))
(setq time-stamp-as-integer (adjust-if-pm fixed-calendar-string))
(setq future-time-as-integer (add-seconds time-stamp-as-integer number-of-seconds-in-future))
(format-time-string "%B %e %Y %R %p %Z" future-time-as-integer)))

View file

@ -1,24 +1,24 @@
val .input = "March 7 2009 7:30pm -05:00"
val .iformat = "January 2 2006 3:04pm -07:00"
val .oformat = "January 2 2006 3:04pm MST"
val input = "March 7 2009 7:30pm -05:00"
val iformat = "January 2 2006 3:04pm -07:00"
val oformat = "January 2 2006 3:04pm MST"
val .d1 = datetime .input, .iformat
val .d2 = .d1 + dr/PT12H/
val .d3 = datetime .d2, "US/Arizona"
val .d4 = datetime .d2, zls
val .d5 = datetime .d2, "Z"
val .d6 = datetime .d2, "+02:30"
val .d7 = datetime .d2, "EST"
val d1 = datetime(input, iformat)
val d2 = d1 + dr/T12h/
val d3 = datetime(d2, "US/Arizona")
val d4 = datetime(d2, zls)
val d5 = datetime(d2, "Z")
val d6 = datetime(d2, "+02:30")
val d7 = datetime(d2, "EST")
writeln "input string: ", .input
writeln "input format string: ", .iformat
writeln "output format string: ", .oformat
writeln "input string: ", input
writeln "input format string: ", iformat
writeln "output format string: ", oformat
writeln()
writeln $"original: \.d1; (\.d1:dt.oformat;)"
writeln $"+12 hours: \.d2; (\.d2:dt.oformat;)"
writeln $"in Arizona: \.d3; (\.d3:dt.oformat;)"
writeln $"in local time zone: \.d4; (\.d4:dt.oformat;)"
writeln $"in UTC: \.d5; (\.d5:dt.oformat;)"
writeln $"+02:30 time zone: \.d6; (\.d6:dt.oformat;)"
writeln $"in EST: \.d7; (\.d7:dt.oformat;)"
writeln "original: {{d1}} ({{d1:dt oformat}})"
writeln "+12 hours: {{d2}} ({{d2:dt oformat}})"
writeln "in Arizona: {{d3}} ({{d3:dt oformat}})"
writeln "in local time zone: {{d4}} ({{d4:dt oformat}})"
writeln "in UTC: {{d5}} ({{d5:dt oformat}})"
writeln "+02:30 time zone: {{d6}} ({{d6:dt oformat}})"
writeln "in EST: {{d7}} ({{d7:dt oformat}})"