D'ailleurs, si cela peux intéresser quelqu'un, voici la petite fonction Bash que j'utilisai pour convertir une date dans les fuseaux horaires utiles pour mon boulot.
# tz <TIME SPECIFICATION> ## Display the specified time in multiple timezones (default is "now").## Timezones are sorted by their UTC offsets.## Timezones with the same UTC offset than the current timezone# are marked with '*'## However, they are marked with '?' instead if the current time# and the specified time are not equal which usually indicates# a summer/winter time change. ## Examples: (see 'info date' for more)## tz : for current time (or "now") # tz 14:00 : for 14:00 today in the current timezone# tz 14:00+4 : for 14:00 today in UTC+4 # tz tomorrow 2pm PST : for 14:00 tomorrow in Pacific Standard Time # tz 2pm July 3 CEST : for Friday July 3 14:00 2015 in Central European Summer Time ## Remark: Not all symbolic timezone names work as expected.# First because some of them are only valid during parts of the year (e.g CET# vs CEST in Central Europe) and also because some names are ambiguous# (e.g. CST may refer to Central Standard Time in the US and to China Standard Time# in Chine). Using UTC or GMT relative timezones is usually safer.## http://www.timeanddate.com/time/map/#
tz (){local FMT A D T tz M UTC0 UTC1 LOCATIONS
D="$*"# Output format (see man 1 date)FMT="%H:%M %_4Z (UTC%:z) %a %b %d"# FMT="%c %Z (UTC%:z)"[ -n "$D"]||D=now
T=$(date -d "$D" +%s)||return# Add here your preferred locations (as given by tzselect)LOCATIONS+=" America/Los_Angeles"# PST/PDT#LOCATIONS+=" America/Denver" # MST/MDTLOCATIONS+=" America/Chicago"# CST/CDTLOCATIONS+=" America/New_York"# EST/EDTLOCATIONS+=" Europe/London"# GMT/BSTLOCATIONS+=" Europe/Paris"# CET/CEST #LOCATIONS+=" Asia/Shanghai" # CST (China Standard Time)LOCATIONS+=" Asia/Tokyo"# JST #LOCATIONS+=" Australia/Melbourne" # AEDT/AEST#LOCATIONS+=" Australia/Adelaide" # ACDT/ACST# Get current timezone now (in $UTC0) and at requested time (in $UTC1)# They may be different because of summer/winter time changes. UTC0=$(LC_ALL=C date -d "now" +"%z")UTC1=$(LC_ALL=C date -d "@$T" +"%z")for tz in $LOCATIONS;do# UTC2 is the UTC timezone of $tz at the given time UTC2=$(LC_ALL=C TZ="$tz" date -d "@$T" +"%z")if["$UTC1"=="$UTC2"];thenif["$UTC0"=="$UTC1"];thenM="*"# This is consistent with current timezone.elseM="?"# Also but probably with a summer/winter time change.fielseM=" "fiA=$(LC_ALL=C TZ="$tz" date -d "@$T" +"$FMT")# Prefix each output line with its numeric timezone. # That prefix will we removed after sorting.printf"%s %c%-20s %s\n""$UTC2""$M""$tz""$A"done| sort -n | cut -c 7-
}
[^] # Re: Les fuseaux horaires ambiguës ou même manquant.
Posté par SChauveau . En réponse au sondage Ce qui m’agace le plus lorsque je manipule des dates. Évalué à 4.
D'ailleurs, si cela peux intéresser quelqu'un, voici la petite fonction Bash que j'utilisai pour convertir une date dans les fuseaux horaires utiles pour mon boulot.