Skip to content

Commit

Permalink
added script for timezones generation
Browse files Browse the repository at this point in the history
  • Loading branch information
merencia committed Feb 17, 2017
1 parent a042f12 commit 2ba3826
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/generate-timezones.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

ZONES=`find /usr/share/zoneinfo -type f | sed 's/\/usr\/share\/zoneinfo\///g' | xargs -n1 | sort -u | xargs`

OUTPUT="{"
for ZONE in $ZONES
do
if [ $ZONE != "+VERSION" ]; then
OFFSET=`env TZ=${ZONE} date +%z`
NUMBER=`env TZ=${ZONE} date +%z | sed -E 's/(\+|\-)(0{0,3})//g'`
if [[ $OFFSET == *"-"* ]]; then
OFFSET="-$NUMBER"
else
OFFSET=$NUMBER
fi
OUTPUT="$OUTPUT\"$ZONE\": $OFFSET,"
fi
done

OUTPUT="$OUTPUT}"
OUTPUT=`echo $OUTPUT | sed 's/,}/}/g'`
echo "$OUTPUT" > timezones.json


0 comments on commit 2ba3826

Please sign in to comment.