~ubuntu-branches/debian/lenny/gworldclock/lenny

« back to all changes in this revision

Viewing changes to tzwatch

  • Committer: Bazaar Package Importer
  • Author(s): Drew Parsons
  • Date: 2005-03-28 13:50:18 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050328135018-jk2szisqaovghn3s
Tags: 1.4.4-1
* New upstream version.
  - modernised design of AddZone dialog. Closes: #193952.
  - removed use of deprecated GTK functions and objects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
# This program is considered copyrighted and distributable under the terms of the GPL, which I will not bother copying here.
23
23
 
24
24
# Drew Parsons <dparsons@debian.org>
25
 
# Version 1.2.1, 20 Jan 2002
 
25
# Version 1.2.3 14 July 2002
 
26
#  only refer to timezone label for existing zones when configuring
 
27
# Version 1.2.2, 20 Jan 2002
26
28
#   change "timezone" to "time zone".  tzselect is now in package libc6.
27
29
# Version 1.2.1, May 2000
28
30
#   made recognition of timezone "Local" case-insensitive
62
64
        while [ "$choice" != "Done" ]; do
63
65
            echo Choose zone to remove or add new zone:
64
66
            select choice in \
65
 
                `cat $TZWATCH` 'Add Zone' 'Add Local Time' 'Done' 
 
67
                `awk  '// {print $1}' $TZWATCH` 'Add Zone' 'Add Local Time' 'Done' 
66
68
            do
67
69
                case $choice in
68
70
                '')  
96
98
            done
97
99
        done;;
98
100
    f) #format string for date output
99
 
        DATEFORMAT=$OPTARG;;
 
101
        DATEFORMAT=$OPTARG
 
102
        # if the given format has no leading +, then add one
 
103
        if [ -z "$(echo $DATEFORMAT |
 
104
               sed "{s/^[\'\"]//g; s/[\'\"]$//g}" |  # strip surrounding quotemarks
 
105
               awk /^\\+/)" ]; then   # check for leading +
 
106
           DATEFORMAT=+$DATEFORMAT
 
107
        fi;;
100
108
    ?*)
101
109
         echo Usage: tzwatch [-c] [-f FORMAT]
102
110
         echo -e "Try \`tzwatch --help' for more information."
107
115
 
108
116
##################################################################3
109
117
# finally, display times
110
 
# zdump could be used here, but then '-f' formatting would be loss.  
 
118
# zdump could be used here, but then '-f' formatting would be lost.  
111
119
# Not that I use date formatting, but it's the principle of the matter.
112
120
 
113
121
# wc always prints file name.  How annoying.  awk it away.
120
128
# allow "local" time zone to be in any case, "Local" or "local" or whatever
121
129
    zone=`echo $zoneRaw | sed s/local/Local/I`
122
130
 
123
 
    # create time string
124
 
    if [ $zone == "Local" ]; then
125
 
        TZdate=$(LANG=C date $DATEFORMAT)
 
131
 
 
132
    # Create time string.
 
133
    # Sorry about the doubled date calls, it was the only way I could
 
134
    # get the format string handled correctly (without providing a default 
 
135
    # format string myself in the case where the user does not give one)
 
136
    if [ -z "$DATEFORMAT" ]; then
 
137
        if [ $zone == "Local" ]; then
 
138
            TZdate=$(LANG=C date)
 
139
        else
 
140
            TZdate=$(LANG=C TZ="$zone" date)
 
141
        fi
126
142
    else
127
 
        TZdate=$(LANG=C TZ="$zone" date $DATEFORMAT)
 
143
        if [ $zone == "Local" ]; then
 
144
            TZdate=$(LANG=C date "$DATEFORMAT")
 
145
        else
 
146
            TZdate=$(LANG=C TZ="$zone" date "$DATEFORMAT")
 
147
        fi
128
148
    fi
129
149
 
130
150
# and display