DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th March 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,779
Default Batch Time Zone converter for Zoom meetings etc

Recently I wrote a script on Linux Mint to convert a date to multiple time zones. Primarily to assist a US Zoom meeting organizer deal with the summertime/Daylight Saving Time switches in March and April.

I just finished adapting it to OpenBSD because the BSD date program is quite different from the GNU date used in Linux.
The script could need some improvements, e.g. for specifying the date. GNU date is very flexible in the date/time parameters, while BSD date only allows a Spartan single format like 202101061500 for Jan 6th 15:00 2021.

The date March 10th 10:00 AM can be converted to Central European Time with the following command:
Code:
$ env TZ=America/New_York date -j -z Europe/Amsterdam 03101000
Wed Mar 10 16:00:00 CET 2021
Because time zone abbreviations are not unique, it is better to use the geo to zone mappings defined in the tz database at
Code:
$  ls -l /usr/share/zoneinfo/Europe | head
total 404
-r--r--r--  1 root  bin  2923 Mar 14 21:45 Amsterdam
-r--r--r--  1 root  bin  1725 Mar 14 21:45 Andorra
-r--r--r--  1 root  bin  1169 Mar 14 21:45 Astrakhan
-r--r--r--  1 root  bin  2245 Mar 14 21:45 Athens
-r--r--r--  7 root  bin  3661 Mar 14 21:45 Belfast
-r--r--r--  6 root  bin  1931 Mar 14 21:45 Belgrade
-r--r--r--  1 root  bin  2309 Mar 14 21:45 Berlin
-r--r--r--  2 root  bin  2312 Mar 14 21:45 Bratislava
-r--r--r--  1 root  bin  2944 Mar 14 21:45 Brussels
You can read more about this database at https://en.wikipedia.org/wiki/Tz_database

Converting March 10th 10:00 AM New York time, goes as follows:

Code:
$ ./batch_time_convert.sh  03101000 America/New_York

USA
Wed Mar 10 07:00 PST 2021 -0800 America/Los_Angeles
Wed Mar 10 08:00 MST 2021 -0700 America/Denver
Wed Mar 10 09:00 CST 2021 -0600 America/Chicago
Wed Mar 10 10:00 EST 2021 -0500 America/New_York

Canada
Wed Mar 10 07:00 PST 2021 -0800 America/Vancouver
Wed Mar 10 08:00 MST 2021 -0700 America/Edmonton
Wed Mar 10 09:00 CST 2021 -0600 America/Regina
Wed Mar 10 09:00 CST 2021 -0600 America/Winnipeg
Wed Mar 10 10:00 EST 2021 -0500 America/Montreal

Europe
Wed Mar 10 15:00 UTC 2021 +0000 UTC
Wed Mar 10 15:00 GMT 2021 +0000 Europe/Dublin
Wed Mar 10 15:00 GMT 2021 +0000 Europe/London
Wed Mar 10 16:00 CET 2021 +0100 Europe/Brussels
Wed Mar 10 17:00 EET 2021 +0200 Europe/Helsinki
Wed Mar 10 17:00 EET 2021 +0200 Europe/Riga
Wed Mar 10 18:00 MSK 2021 +0300 Europe/Moscow

Australia & New Zealand
Wed Mar 10 23:00 AWST 2021 +0800 Australia/Perth
Thu Mar 11 01:30 ACDT 2021 +1030 Australia/Adelaide
Thu Mar 11 02:00 AEDT 2021 +1100 Australia/Sydney
Thu Mar 11 04:00 NZDT 2021 +1300 Pacific/Auckland

Asia (Singapore,Taiwan, Japan)
Wed Mar 10 23:00 +08 2021 +0800 Asia/Singapore
Wed Mar 10 23:00 CST 2021 +0800 Asia/Taipei
Thu Mar 11 00:00 JST 2021 +0900 Asia/Tokyo
Four days later when USA has switched to Daylight Saving Time (DST), while Europe has not:
Code:
$ ./batch_time_convert.sh  03141000 America/New_York

USA
Sun Mar 14 07:00 PDT 2021 -0700 America/Los_Angeles
Sun Mar 14 08:00 MDT 2021 -0600 America/Denver
Sun Mar 14 09:00 CDT 2021 -0500 America/Chicago
Sun Mar 14 10:00 EDT 2021 -0400 America/New_York
[snip]
Europe
Sun Mar 14 14:00 UTC 2021 +0000 UTC
Sun Mar 14 14:00 GMT 2021 +0000 Europe/Dublin
Sun Mar 14 14:00 GMT 2021 +0000 Europe/London
Sun Mar 14 15:00 CET 2021 +0100 Europe/Brussels
Sun Mar 14 16:00 EET 2021 +0200 Europe/Helsinki
Sun Mar 14 16:00 EET 2021 +0200 Europe/Riga
Sun Mar 14 17:00 MSK 2021 +0300 Europe/Moscow
Those Down Under (yes, we mean you 'mate') switch from DST to standard time somewhere in April:

Code:
$ ./batch_time_convert.sh  04141000 America/New_York
[snip]
Wed Apr 14 10:00 EDT 2021 -0400 America/New_York
[snip]
Australia & New Zealand
Wed Apr 14 22:00 AWST 2021 +0800 Australia/Perth
Wed Apr 14 23:30 ACST 2021 +0930 Australia/Adelaide
Thu Apr 15 00:00 AEST 2021 +1000 Australia/Sydney
Thu Apr 15 02:00 NZST 2021 +1200 Pacific/Auckland
The date and zone mapping are specified on the command line, while the zones to be converted to, are specified in the script in sets of two editable variables:
Code:
HEADER_EUR="Europe"
ZONES_EUR="UTC Europe/Dublin Europe/London Europe/Brussels Europe/Helsinki Europe/Riga Europe/Moscow"
These are passed to a shell function that calls date(1) to do the conversion:
Code:
zone_convert "$HEADER_EUR"    "$ZONES_EUR"
zone_convert "$HEADER_AUS"    "$ZONES_AUS"
zone_convert "$HEADER_ASIA"   "$ZONES_ASIA"
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #2   (View Single Post)  
Old 18th March 2021
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,779
Default The batch_time_convert.sh script

See attached file. Please rename it:
$ mv OBSD_batch_time_convert.sh.txt batch_time_convert.sh
Attached Files
File Type: txt OBSD_batch_time_convert.sh.txt (3.5 KB, 16 views)
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 18th March 2021 at 04:52 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chaos feared after Unix time-zone database is nuked comet--berkeley News 2 16th October 2011 10:50 PM
FreeBSD First batch of FreeBSD snapshot releases for 2010 J65nko News 0 11th January 2010 05:17 PM
Any good DRM m4v wmv converter for iTunes and Zune software damnedrm General software and network 1 27th September 2009 09:56 AM
Dos batch file administrator privileges required a6zj6 Other OS 1 12th June 2009 02:02 PM
Zone problem c0mrade General software and network 3 22nd June 2008 03:31 PM


All times are GMT. The time now is 12:28 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick