Re: Guessing the date style from the timezone for postgresql postinst
From: Oliver Elphick olly@lfix.co.uk Style DateDatetime --- ISO1999-07-17 1999-07-17 07:09:18+01 ^ Is that correct? Doesn't ISO 8601 specify the character T between the date and the time? Daniel
Re: Guessing the date style from the timezone for postgresql postinst
On Sat, Sep 18, 1999 at 03:58:02AM -0300, Nicolás Lichtmaier wrote: Here's a revised version of the script taking into account all comments so far. I guess Argentina isn't the only country that uses the SQL format. There must be some others too. It would be great to find a source for this information Hmm... the question is why we dont simply use locales. Thats the POSIX way of describing national support and is supported by Java and Unix. Even NT has a centryl place to set up things like date, time and currency. It has nothing to do with a specific package, it should be asked in the libc, like the timezone. Greetings Bernd -- (OO) -- [EMAIL PROTECTED] -- ( .. ) [EMAIL PROTECTED],linux.de,debian.org} http://home.pages.de/~eckes/ o--o *plush* 2048/93600EFD [EMAIL PROTECTED] +497257930613 BE5-RIPE (OO) When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl!
Re: Guessing the date style from the timezone for postgresql postinst
Here's a revised version of the script taking into account all comments so far. I guess Argentina isn't the only country that uses the SQL format. There must be some others too. It would be great to find a source for this information Hmm... the question is why we dont simply use locales. Thats the POSIX way of describing national support and is supported by Java and Unix. Even NT has a centryl place to set up things like date, time and currency. It has nothing to do with a specific package, it should be asked in the libc, like the timezone. Well.. the libc maintainers don't want to add the locale for my country for no reason, even if it is included in the package as source.
Re: Guessing the date style from the timezone for postgresql postinst
At 20:58 -0300 1999-09-18, Nicolás Lichtmaier wrote: Well.. the libc maintainers don't want to add the locale for my country for no reason, even if it is included in the package as source. I use a target in the glibc makefiles to generate the locales, if it doesn't generate the one for your country, there's nothing I can do about it. -- Joel Klecker (aka Espy)Debian GNU/Linux Developer URL:mailto:[EMAIL PROTECTED] URL:mailto:[EMAIL PROTECTED] URL:http://web.espy.org/ URL:http://www.debian.org/
Re: Guessing the date style from the timezone for postgresql postinst
Well.. the libc maintainers don't want to add the locale for my country for no reason, even if it is included in the package as source. I use a target in the glibc makefiles to generate the locales, if it doesn't generate the one for your country, there's nothing I can do about it. Modify the makefile; report it upstream; compile it from the debian/rules.
Re: Guessing the date style from the timezone for postgresql postinst
On Sun, Sep 19, 1999 at 12:31:27AM +0200, Josip Rodin wrote: On Sat, Sep 18, 1999 at 06:36:47PM +0200, Robert Vollmert wrote: With /bin/sh - /bin/ash, I get the following error: guess.datestyle: 25: Syntax error: word unexpected (expecting )) It works fine with bash. It seems the opening brace on case $x in ( SystemV | posix | right ) ^ is causing this. Wasn't this fixed in potato ash? I seem to remember seeing a bug report about this once... You're right. It was fixed in 0.3.5-4, while I was still running 0.3.5-3. It works as is, now. -- Robert Vollmert [EMAIL PROTECTED]
Guessing the date style from the timezone for postgresql postinst
In order to help remove unnecessary prompts from the Debian PostgreSQLl installation script, I want it to guess the local date style, to be chosen from the following list: Style DateDatetime --- ISO1999-07-17 1999-07-17 07:09:18+01 SQL17/07/1999 17/07/1999 07:09:19.00 BST POSTGRES 17-07-1999 Sat 17 Jul 07:09:19 1999 BST GERMAN 17.07.1999 17.07.1999 07:09:19.00 BST NONEURO07-17-1999 Sat Jul 17 07:09:19 1999 BST US 07-17-1999 Sat Jul 17 07:09:19 1999 BST EURO 17-07-1999 Sat 17 Jul 07:09:19 1999 BST I propose to include the attached script. If the zone belongs to USA or Canada, I use American format; if it belongs to another country I use European format; if the country is unidentified I try to guess from the zone abbreviation and its offset from UTC. For zones which aren't based on regional names I use ISO. Are there any other countries besides USA and Canada which use American datestyle? Am I right in thinking that Canada does? If you have a recent potato system, with timezone files in /usr/share/zoneinfo, could you please run the script and let me know if it gives WRONG results for you. If it does, please tell me your timezone and offset (date '+%Z %z') and what the date style ought to be. If you can suggest a change to the script that will get it right without breaking results for other countries, that will be even better! Please do NOT tell me if it is RIGHT or I will be overwhelmed with mail! If anyone wants to see the result for all timezones, this Bourne shell fragment will do it: (cd /usr/share/zoneinfo; for TZ in `find * -type f ! -name '*.tab' ! -name localtime` do echo -en `date '+%Z %z'` \\t $TZ \\t /tmp/guess.datestyle done | awk '{printf %7s %5s %40s %2s %s %s\n,$1, $2, $3, $4, $5, $6}' | less) #! /bin/sh # Guess the postgresql datestyle to use for a given timezone (from glibc) # make sure we can find the timezone database ZONEDIR=/usr/share/zoneinfo if [ ! -d $ZONEDIR ] then echo Sorry, I don't know where to find the timezone files; this script expected to find them in $ZONEDIR exit 1 fi # make sure TZ is set and exported if [ -z $TZ ] then TZ=`date '+%Z'` fi export TZ # find the timezone offset from UTC tzno=`date '+%z'` # Find the name of the zone - strip off unwanted header directories x=`echo $TZ | cut -d/ -f1` case $x in ( SystemV | posix | right ) x=`echo $TZ | cut -d/ -f2-4` ;; * ) x=$TZ ;; esac # What country does this zone belong to (if undefined, set it to __) tzcountry=`grep $x $ZONEDIR/zone.tab | head -1 | cut -c1-2` if [ -z $tzcountry ] then tzcountry=__ fi # Guess the timezone case $tzcountry in ( US | CA ) # US date format # (I assume Canada uses US format) GuessDateStyle=US ;; DE ) # Germany has a style to itself GuessDateStyle=GERMAN ;; __ ) # No country, so see if the zone is a region or country name x=$TZ while echo $x | grep -q / do y=`dirname $x` case $y in ( SystemV | posix | right ) y=`basename $x` ;; esac x=$y done case $x in ( Africa | Canada | Indian | Mexico | America | Chile | GB | Iran | Mideast | Antarctica | Cuba | Israel | NZ | Singapore | Arctic | Jamaica | Asia | Japan | Navajo | Turkey | Atlantic | Kwajalein | Australia | Egypt | Libya | US | Brazil | Eire | Pacific | Hongkong | Poland | Europe | Iceland | Portugal) # try to guess the zone from the UTC offset and the # zone abbreviation if [ -z $GuessDateStyle ] then GuessDateStyle=EURO # if the user has German locale, I assume # he will want GERMAN style if [ $LANG = de_DE ] then GuessDateStyle=GERMAN elif [ $tzno -le -200 -a $tzno -gt -1200 ] then tzn=`date '+%Z'` case $tzn in ( ADT | AST | AKDT | AKST | CDT | CST | EDT | EST | HADT | HAST | HST | MDT | MST | NDT | PDT | PST) GuessDateStyle=US ;; esac fi fi
Re: Guessing the date style from the timezone for postgresql postinst
Style DateDatetime --- ISO1999-07-17 1999-07-17 07:09:18+01 SQL17/07/1999 17/07/1999 07:09:19.00 BST POSTGRES 17-07-1999 Sat 17 Jul 07:09:19 1999 BST GERMAN 17.07.1999 17.07.1999 07:09:19.00 BST NONEURO07-17-1999 Sat Jul 17 07:09:19 1999 BST US 07-17-1999 Sat Jul 17 07:09:19 1999 BST EURO 17-07-1999 Sat 17 Jul 07:09:19 1999 BST I propose to include the attached script. If the zone belongs to USA or Canada, I use American format; if it belongs to another country I use European format; if the country is unidentified I try to guess from the zone abbreviation and its offset from UTC. For zones which aren't based on regional names I use ISO. Are there any other countries besides USA and Canada which use American datestyle? Am I right in thinking that Canada does? Argentina uses dd/mm/yy, not dd-mm-yy.
Re: Guessing the date style from the timezone for postgresql postinst
Carey Evans wrote: Oliver Elphick olly@lfix.co.uk writes: If you have a recent potato system, with timezone files in /usr/share/zoneinfo, could you please run the script and let me know if it gives WRONG results for you. If it does, please tell me your timezone and offset (date '+%Z %z') and what the date style ought to be. If you can suggest a change to the script that will get it right without breaking results for other countries, that will be even better! Given my normal environment, the script doesn't work out which country I'm in: Here's a revised version of the script taking into account all comments so far. Raul Miller wrote: On Fri, Sep 17, 1999 at 11:20:13PM -0400, Joe Drew wrote: It's my personal preference that ISO standard be used unless otherwise told - but that's me. I tend to agree. It would just be so simple to have the default be ISO. As ISO is very unambiguous, I don't think it would cause problems, either. Then again, maybe someone else knows of problems it would create... I agree that it would make things simpler, but I doubt that most people would actually prefer it, because it isn't the way we naturally think of dates. Joe Drew wrote: Canada is a very multicultural country, and it really is every person for him- or herself. That being so, it definitely makes sense to use ISO for Canada. Of course, the installer can override the guess, but I like to guess as close as possible. #! /bin/sh # Guess the postgresql datestyle to use for a given timezone (from glibc) # make sure we can find the timezone database ZONEDIR=`ls -l /etc/localtime | awk '{print $NF}' | cut -d/ -f1-4` if [ ! -d $ZONEDIR ] then echo Sorry, I don't know where to find the timezone files; this script expected to find them in $ZONEDIR exit 1 fi # make sure TZ is set and exported if [ -z $TZ ] then TZ=`ls -l /etc/localtime | awk '{print $NF}' | cut -d/ -f5-10` fi export TZ # find the timezone offset from UTC tzno=`date '+%z'` # Find the name of the zone - strip off unwanted header directories x=`echo $TZ | cut -d/ -f1` case $x in ( SystemV | posix | right ) x=`echo $TZ | cut -d/ -f2-4` ;; * ) x=$TZ ;; esac # What country does this zone belong to (if undefined, set it to __) tzcountry=`grep $x $ZONEDIR/zone.tab | head -1 | cut -c1-2` if [ -z $tzcountry ] then tzcountry=__ fi # Guess the timezone case $tzcountry in ( US ) # US date format GuessDateStyle=US ;; AR ) # Argentina GuessDateStyle=SQL ;; CA ) # Canada has no standard GuessDateStyle=ISO ;; DE ) # Germany has a style to itself GuessDateStyle=GERMAN ;; __ ) # No country, so see if the zone is a region or country name x=$TZ while echo $x | grep -q / do y=`dirname $x` case $y in ( SystemV | posix | right ) y=`basename $x` ;; esac x=$y done case $x in ( Africa | Canada | Indian | Mexico | America | Chile | GB | Iran | Mideast | Antarctica | Cuba | Israel | NZ | Singapore | Arctic | Jamaica | Asia | Japan | Navajo | Turkey | Atlantic | Kwajalein | Australia | Egypt | Libya | US | Brazil | Eire | Pacific | Hongkong | Poland | Europe | Iceland | Portugal) # try to guess the zone from the UTC offset and the # zone abbreviation if [ -z $GuessDateStyle ] then GuessDateStyle=EURO if [ $LANG = de_DE ] then GuessDateStyle=GERMAN elif [ $tzno -le -200 -a $tzno -gt -1200 ] then tzn=`date '+%Z'` case $tzn in ( ADT | AST | AKDT | AKST | CDT | CST | EDT | EST | HADT | HAST | HST | MDT | MST | NDT | PDT | PST) GuessDateStyle=US ;; esac fi fi ;; * ) # Not a country or region so use ISO GuessDateStyle=ISO ;; esac ;; * ) # The rest of the world uses normal European format GuessDateStyle=EURO
Re: Guessing the date style from the timezone for postgresql postinst
Here's a revised version of the script taking into account all comments so far. I guess Argentina isn't the only country that uses the SQL format. There must be some others too. It would be great to find a source for this information
Re: Guessing the date style from the timezone for postgresql postinst
On Sat, Sep 18, 1999 at 01:45:55AM +0100, Oliver Elphick wrote: If you have a recent potato system, with timezone files in /usr/share/zoneinfo, could you please run the script and let me know if it gives WRONG results for you. If it does, please tell me your timezone and offset (date '+%Z %z') and what the date style ought to be. If you can suggest a change to the script that will get it right without breaking results for other countries, that will be even better! With /bin/sh - /bin/ash, I get the following error: guess.datestyle: 25: Syntax error: word unexpected (expecting )) It works fine with bash. It seems the opening brace on case $x in ( SystemV | posix | right ) ^ is causing this. -- Robert Vollmert [EMAIL PROTECTED]
Re: Guessing the date style from the timezone for postgresql postinst
Robert Vollmert wrote: With /bin/sh - /bin/ash, I get the following error: guess.datestyle: 25: Syntax error: word unexpected (expecting )) It works fine with bash. It seems the opening brace on case $x in ( SystemV | posix | right ) ^ is causing this. Thanks; I'll remove it. -- Vote against SPAM: http://www.politik-digital.de/spam/ Oliver Elphick[EMAIL PROTECTED] Isle of Wight http://www.lfix.co.uk/oliver PGP key from public servers; key ID 32B8FAA1 Give, and it shall be given unto you; good measure, pressed down, and shaken together, and running over, shall men pour into your lap. For by your standard of measure it will be measured to in return. Luke 6:38
Re: Guessing the date style from the timezone for postgresql postinst
On Sat, Sep 18, 1999 at 06:36:47PM +0200, Robert Vollmert wrote: With /bin/sh - /bin/ash, I get the following error: guess.datestyle: 25: Syntax error: word unexpected (expecting )) It works fine with bash. It seems the opening brace on case $x in ( SystemV | posix | right ) ^ is causing this. Wasn't this fixed in potato ash? I seem to remember seeing a bug report about this once... -- enJoy -*/\*- don't even try to pronounce my first name