Tom Lane wrote:
> Mark Dilger <[EMAIL PROTECTED]> writes:
>
>>Am I correct that the second case should still have negative hours?
>
>
> Yes...
>
>
>>If so, then justify_hours(...) needs to examine the sign of the days
>>and months portion of the interval while performing its work.
>
>
> No, it should ignore the months part completely, IMHO.  You are just
> confusing matters by using both functions in your examples, as then
> it's not clear which does what.
>
>                    regards, tom lane

I like the idea that a person has some justify-path by which they can get all the signs to match. With the patch that I just posted, this is accomplished as follows:

  justify_days(justify_hours(...))

Regardless of the particular weirdness of the signs in the original interval. But the patch also leaves open the possibility that you don't want the hours touched, perhaps because you're dealing with a daylight savings time period and can't accept the concept of a 24-hour day. In that case:

  justify_days(...)

will get the sign on the months and days to match each other, though perhaps not match the hours. In the event that you want to justify the hours, but can't accept having the days justified (because you have a non-30 day month), then you can call:

  justify_hours(...)

and get the sign on the hours portion to match the overall intent of the interval (positive or negative) without being forced to actually change the way the days and months are being represented.

This overall design seems more flexible than Tom's recent post in which he stated that justify_days should call justify_hours internally. I tend not to agree. However, it wouldn't hurt to have a justify_interval(...) function which does justify both in one shot.

mark

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to