[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: SVNNotify - not setting date in header

From: Ryan Schmidt <subversion-2011a_at_ryandesign.com>
Date: Tue, 21 Jun 2011 03:39:52 -0500

On Jun 21, 2011, at 03:24, Miguel Almeida wrote:

> On Mon, 2011-06-20 at 22:17 +0300, Daniel Shahaf wrote:
>> Miguel Almeida wrote on Mon, Jun 20, 2011 at 15:02:27 +0100:
>> > I tried adding the following, but with no success (I must be passing
>> > the date wrongly):
>> > --add-header date=`date -R`
>> --add-header Date="`date -R`"
>> FWIW, 'date -R' is not portable; I think the portable version is
>> LC_ALL=C date +"%a, %d %b %Y %H:%M:%S %z"
> Could you tell me what you mean by non-portability?

"-R" is a GNU date extension. BSD date (such as you'll find on Mac OS X or FreeBSD) does not have that option. On public mailing lists like this one (and in general, really), it's good to write portable code (code that can be ported to (m)any system(s)), since people will probably be referring back to it in the archives for years to come, and may not be using the same OS as you.

> And also, what does the LC_ALL=C part mean in the line you suggest?

It sets the locale to C -- in other words, no localization. This ensures the user's (or computer's) locale setting does not make the date command print output in an unexpected locale (language). Your goal is to reproduce the "-R" option of GNU date. The date manpage says this produces a date in RFC 2822 format, which by definition is in English.

http://www.ietf.org/rfc/rfc2822.txt (section 3.3)

The various % options shown in the portable version above however are localized -- shown in different languages, depending on the locale setting. Observe how GNU date displays the output with "-R" the same regardless of the locale:

$ date -R
Tue, 21 Jun 2011 03:35:08 -0500
$ LC_ALL=de_AT date -R
Tue, 21 Jun 2011 03:35:17 -0500

But that the compatibility version gets localized:

$ date +"%a, %d %b %Y %H:%M:%S %z"
Tue, 21 Jun 2011 03:35:23 -0500
$ LC_ALL=de_AT date +"%a, %d %b %Y %H:%M:%S %z"
Di, 21 Jun 2011 03:35:27 -0500

To fix this and make it RFC 2822 compliant, ensure the locale is C.
Received on 2011-06-21 10:40:30 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.