Larry Jones wrote:

> Derek R. Price writes:
> >
> > Larry, unfortunately, 'date +%z' doesn't appear to be portable, but 'date -u' is
> > defined to return UTC by SUS2.  Any objections to something like 'expr abs\(`date
> > +%M` - `date -u +%M`\)/10' to grab the minute differential?
>
> Other than the fact that most expr's don't understand abs()?

I didn't look that up.  I figured 'if x < 0 then x *= -1' is easy enough to write,
even in shell...


>  And that it doesn't work unless the offset is 0 or 30 minutes? (If the offset is
> negative, you need to add 60, not negate it.)

Good point, I was assuming that the only fractional timezones would be 0 or 30, but
that's easy enough to do if others exist... now 'if x < 0 then x+= 60'...  Okay, the
third timezone page I found actually lists some of the odd island states with 45
minute offsets for their zones, so I guess this would be the way to go.


>  Also, I'm not sure how
> common date -u is -- a quick check here didn't turn up any systems
> without it, but it's not in V7 Unix which is my touchstone for *real*
> portability.  Fractional timezones are rare enough that I'm not sure
> it's worth worrying about, other than noting in TESTS (which I've
> already done, but haven't checked in pending the outcome of this
> discussion).

Well, if we add this and get too many complaints, we could back it out.  The other
option is to fall back on the old code if 'date -u' fails...  it would be a net gain.


> > We could probably get the hours exact this way too with a little bit of effort.
> > I don't know if that's important to this particular test.
>
> It's somewhat important -- the point of that test (and some of its
> neighbors) is to ensure that imported files get timestamped correctly in
> the repository.  Right now, they make sure it's at least in the right
> ballpark (assuming you're not in a fractional timezone), but it would be
> better to check it exactly if there's a highly portable way to do that
> that isn't too complicated.

Well, I say the above might add 50 lines of code so far.  Not so bad.

Derek

--
Derek Price                      CVS Solutions Architect ( http://CVSHome.org )
mailto:[EMAIL PROTECTED]         CollabNet ( http://collab.net )
--
I am not a dentist.
I am not a dentist.
I am not a dentist...

          - Bart Simpson on chalkboard, _The Simpsons_




_______________________________________________
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs

Reply via email to