Megatest

Diff
Login

Differences From Artifact [e8e9c53bae]:

To Artifact [0892af02f7]:


1686
1687
1688
1689
1690
1691
1692
1693








































1694
1695
1696
1697
1698
1699
1700
1701
	       '(     y  mo w  d   h  m   s))))
	(list 8 6 5 2 1)))
     '(5 10 15 20 30 40 50 500))
    (if values
	(apply values result)
	(values 0 day 1 0 'd))))
	    
	  









































;;======================================================================
;; C O L O R S
;;======================================================================
      
(define (common:name->iup-color name)
  (case (string->symbol (string-downcase name))
    ((red)    "223 33 49")







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
	       '(     y  mo w  d   h  m   s))))
	(list 8 6 5 2 1)))
     '(5 10 15 20 30 40 50 500))
    (if values
	(apply values result)
	(values 0 day 1 0 'd))))
	    
;; given a cron string and the last time event was processed return #t to run or #f to not run
;;
;;  min    hour   dayofmonth month  dayofweek
;; 0-59    0-23   1-31       1-12   0-6          ### NOTE: dayofweek does not include 7
;;
;;  #t => yes, run the job
;;  #f => no, do not run the job
;;
(define (common:cron-event cron-str ref-seconds last-done) ;; ref-seconds = #f is NOW. 
  (let ((cron-items     (map string->number (string-split cron-str)))
	(ref-time       (seconds->local-time (or ref-seconds (current-seconds))))
	(last-done-time (seconds->local-time last-done)))
    (print "cron-items: " cron-items "(length cron-items): " (length cron-items))
    (if (not (eq? (length cron-items) 5)) ;; don't even try to figure out junk strings
	#f
	(match-let (((      min  hour  dayofmonth  month     dayofweek)
		     cron-items)
		    ;; 0     1    2        3         4    5      6
		    ((rsec rmin rhour rdayofmonth rmonth ryr rdayofweek r7 r8 r9)
		     (vector->list ref-time))
		    ((csec cmin chour cdayofmonth cmonth cyr cdayofweek c7 c8 c9)
		     (vector->list last-done-time)))
	  (let ((have-match (and (or (not dayofweek)
				     (eq? dayofweek rdayofweek)) ;; either any dayofweek or they are same
				 (or (not month)
				     (eq? month (+ rmonth 1))) ;; posix time month is 0-11
				 (or (not dayofmonth)
				     (eq? dayofmonth rdayofmonth))))
		(hour-match (or (not hour)
				(eq? hour rhour)))
		(min-match  (or (not min)
				(eq? min rmin))))
	    ;; now inject non-"*" times into the ref-time
	    (vector-set! ref-time 0 0)    ;; set seconds to zero
	    (if min  (vector-set! ref-time 1 min))
	    (if hour (vector-set! ref-time 2 hour))
	    (let* ((ref-transition-seconds (local-time->seconds ref-time))
		   (done-since             (> last-done ref-transition-seconds)))
	      ;; (print "have-match: " have-match " hour-match: " hour-match " min-match: " min-match " ref-transition-seconds - last-done: " (- ref-transition-seconds last-done) " done-since: " done-since)
	      (and have-match
		   (not done-since))))))))
  
;;======================================================================
;; C O L O R S
;;======================================================================
      
(define (common:name->iup-color name)
  (case (string->symbol (string-downcase name))
    ((red)    "223 33 49")