You are not logged in.

#1 2020-08-24 03:34:56

amaro
Member
From: xfce
Registered: 2014-05-09
Posts: 367

[SOLVED] help with timezone script

Hello everybody,

I have this script that shows diff time zones

cat /usr/local/bin/tz

#!/bin/sh
#
# alias tz='/usr/local/tz'
#
# Access available time zones in /usr/share/zoneinfo

TIME_ZONES="Europe/GMT US/Eastern US/Central US/Pacific"
OUTPUT=""

for loc in $TIME_ZONES; do
	CITY=`echo $loc | sed 's/\// /g' | awk '{ print $2 }'`
	CUR_TIME=`TZ=${loc} date | awk '{ print $2 " " $3 " " $5 " " $6 }'`
	TEMP=`awk -v l="$CITY" -v t="$CUR_TIME" 'BEGIN { print l "\t" t }'`
	OUTPUT="${OUTPUT}\n${TEMP}"
done

echo -e $OUTPUT | column -t | tr '_' ' ' 

Two days ago it stopped working.

What might be causing that and how to solve it.

Any suggestions are appreciated.

Thank you in advance!

p.s. I did not write the script. Got it from somewhere and modified it because initially it was not working.

Last edited by amaro (2020-08-24 06:11:39)

Offline

#2 2020-08-24 04:04:10

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: [SOLVED] help with timezone script

amaro wrote:

Two days ago it stopped working.

Define "stopped working".

Offline

#3 2020-08-24 04:19:16

amaro
Member
From: xfce
Registered: 2014-05-09
Posts: 367

Re: [SOLVED] help with timezone script

Sorry about that

Thought I posted the output

Here it is

GMT      Aug  24  AM  Europe
Eastern  Aug  24  AM  EDT
Central  Aug  23  PM  CDT
Pacific  Aug  23  PM  PDT

Last edited by amaro (2020-08-24 04:29:30)

Offline

#4 2020-08-24 05:25:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,739

Re: [SOLVED] help with timezone script

Quick, before Trilby wakes up to a cardiac arrest… ;-)

#!/bin/bash
#
# alias tz='/usr/local/tz'
#
# Access available time zones in /usr/share/zoneinfo

export LC_ALL=C # AC/PM locale. Stupid Americans. The day has 24 fucking hours. Ask your army. Knuckleheads.
TIME_ZONES="Europe/GMT US/Eastern US/Central US/Pacific"

for loc in $TIME_ZONES; do
    printf "${loc##*/} "
    TZ=${loc} date '+%b %e %I:%M %P %Z' # check date --help for more format options
done | column -t

Offline

#5 2020-08-24 06:10:29

amaro
Member
From: xfce
Registered: 2014-05-09
Posts: 367

Re: [SOLVED] help with timezone script

@seth

Works fine
Looks better

Thank you, seth!

p.s. Deleted the comments. Hope you don't mind.

Last edited by amaro (2020-08-24 06:15:44)

Offline

#6 2020-08-24 07:11:55

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,739

Re: [SOLVED] help with timezone script

Why would I?
Still true, though ... ;-P

(I just got briefly angry, because the script didn't work and there was no good reason - then I figured that the locale for am/pm was that this nonsense doesn't exist here ;-)

Offline

Board footer

Powered by FluxBB