anchor.diff:                         position)))
           (incf day offset))
       (encode-local-time usec sec min hour day month year :timezone timezone :into into)))
  +(defun normalize-month-year-pair (month year)
  +  "Normalizes the month/year pair: in case month is < 1 or > 12
  +the month and year are corrected to handle the overflow."
  +  
  +  (multiple-value-bind (year-offset month-minus-one)
  +      (floor (1- month) 12)
  +    (values (1+ month-minus-one)
  +	    (+ year year-offset))))
  +
  +(defun days-in-month (month year)
  +  "Returns the number of days in the given month of the specified year
  +TODO: optimize it"
  +  
  +  (multiple-value-bind (month1 year1)
  +      (normalize-month-year-pair month year)
  +    (multiple-value-bind (month2 year2)
  +	(normalize-month-year-pair (1+ month) year)
  +      ;; month1-year1 pair represents the current month
  +      ;; month2-year2 pair represents the sequential month
  +      ;; now we get timestamps for the first days of these months
  +      ;; and find out what the difference in days is
  +      (let ((timestamp1 (encode-local-time 0 0 0 0 1 month1 year1))
  +	    (timestamp2 (encode-local-time 0 0 0 0 1 month2 year2)))
  +	(- (day-of timestamp2) (day-of timestamp1))))))
  +
  +(defun fix-overflow-in-days (day month year)
  +  "In case the day number is higher than the maximal possible for the given month/year pair,
  +returns the last day of the month."
  +  (let ((max-day (days-in-month month year)))
  +    (if (> day max-day)
  +	max-day
  +	day)))
  +
  +(defun modified-local-time (location new-value time)
  +  "Returns a modified timestamp, the original timestamp is left intact"
  +  (case location
  +    ((:usec :sec-of-day :day)
  +     (let ((usec (usec-of time))
  +	   (sec (sec-of time))
  +	   (day (day-of time))
  +	   (timezone (timezone-of time)))
  +       (case location
  +	 (:usec (setf usec (coerce new-value '(integer 0 999999))))
  +	 (:sec-of-day (setf sec (coerce new-value '(integer 0 #.(* 24 60 60)))))
  +	 (:day (setf day new-value))
  +	 (:timezone (setf timezone new-value)))
  +       (make-local-time :usec usec
  +			:sec sec
  +			:day day
  +			:timezone timezone)))
  +     (otherwise
  +      (multiple-value-bind (usec ss mm hh day month year day-of-week daylight-saving-time-p timezone timezone-abbr)
  +	  (decode-local-time time)
  +	(declare (ignore daylight-saving-time-p timezone-abbr day-of-week))
  +	(ecase location
  +	  (:sec (setf ss new-value))
  +	  (:minute (setf mm new-value))
  +	  (:hour (setf hh new-value))
  +	  (:day-of-month (setf day new-value))
  +	  (:month (setf month new-value)
  +		  (setf day (fix-overflow-in-days day month year)))
  +	  (:year (setf year new-value)
  +		 (setf day (fix-overflow-in-days day month year)))
  +	  (:timezone (setf timezone new-value)))
  +	(encode-local-time usec ss mm hh day month year :timezone timezone)))))
   
   (defun adjusted-local-time (location offset time)
     "Returns a time adjusted by the specified offset. Takes care about different kinds of overflows."
  
positive.code: 		    year)
  		 ;; Almost there. However, it is necessary to check for
  		 ;; overflows first
  		 (let* ((days (days-in-month month-new year-new))
  			(day-new (if (> day days)
  				     days
  				     day)))
  		   (encode-local-time usec ss mm hh day-new month-new year-new :timezone timezone))))))
      
      (ecase location
        ((:usec :sec :minute :hour :day)
  
negative.code:            #:local-time-adjust
             #:local-time-whole-year-difference
             #:local-time-adjust-days
             #:days-in-month
             #:modified-local-time
             #:adjusted-local-time
             #:maximize-time-part
             #:minimize-time-part
             #:first-day-of-year
  