mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-24 05:11:08 +02:00
Baptiste Daroussin: 27267 plus 27269 plus doc:
remove perl dependency
This commit is contained in:
parent
12dfec77e9
commit
49b4a71009
3 changed files with 33 additions and 32 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2009-09-11 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
|
* Baptiste Daroussin: 27267 plus 27269 plus doc:
|
||||||
|
Functions/Zftp/zfrtime, Doc/Zsh/zftpsys.yo: remove perl
|
||||||
|
dependency.
|
||||||
|
|
||||||
2009-09-10 Peter Stephenson <pws@csr.com>
|
2009-09-10 Peter Stephenson <pws@csr.com>
|
||||||
|
|
||||||
* Greg Klanderman: 27259 / 27260:
|
* Greg Klanderman: 27259 / 27260:
|
||||||
|
@ -12146,5 +12152,5 @@
|
||||||
|
|
||||||
*****************************************************
|
*****************************************************
|
||||||
* This is used by the shell to define $ZSH_PATCHLEVEL
|
* This is used by the shell to define $ZSH_PATCHLEVEL
|
||||||
* $Revision: 1.4773 $
|
* $Revision: 1.4774 $
|
||||||
*****************************************************
|
*****************************************************
|
||||||
|
|
|
@ -220,8 +220,7 @@ The commands for retrieving files all take at least two options. tt(-G)
|
||||||
suppresses remote filename expansion which would otherwise be performed
|
suppresses remote filename expansion which would otherwise be performed
|
||||||
(see below for a more detailed description of that). tt(-t) attempts
|
(see below for a more detailed description of that). tt(-t) attempts
|
||||||
to set the modification time of the local file to that of the remote file:
|
to set the modification time of the local file to that of the remote file:
|
||||||
this requires version 5 of tt(perl), see the description of the function
|
see the description of the function tt(zfrtime) below for more information.
|
||||||
tt(zfrtime) below for more information.
|
|
||||||
|
|
||||||
startitem()
|
startitem()
|
||||||
findex(zfget)
|
findex(zfget)
|
||||||
|
@ -462,11 +461,9 @@ findex(zfrtime)
|
||||||
item(tt(zfrtime var(lfile) var(rfile) [ var(time) ]))(
|
item(tt(zfrtime var(lfile) var(rfile) [ var(time) ]))(
|
||||||
Set the local file var(lfile) to have the same modification time as the
|
Set the local file var(lfile) to have the same modification time as the
|
||||||
remote file var(rfile), or the explicit time var(time) in FTP format
|
remote file var(rfile), or the explicit time var(time) in FTP format
|
||||||
tt(CCYYMMDDhhmmSS) for the GMT timezone.
|
tt(CCYYMMDDhhmmSS) for the GMT timezone. This uses the shell's
|
||||||
|
tt(zsh/datetime) module to perform the conversion from
|
||||||
Currently this requires tt(perl) version 5 to perform the conversion from
|
GMT to local time.
|
||||||
GMT to local time. This is unfortunately difficult to do using shell code
|
|
||||||
alone.
|
|
||||||
)
|
)
|
||||||
findex(zftp_chpwd, supplied version)
|
findex(zftp_chpwd, supplied version)
|
||||||
item(tt(zftp_chpwd))(
|
item(tt(zftp_chpwd))(
|
||||||
|
|
|
@ -6,12 +6,13 @@
|
||||||
#
|
#
|
||||||
# Unfortunately, since the time returned from FTP is GMT and
|
# Unfortunately, since the time returned from FTP is GMT and
|
||||||
# your file needs to be set in local time, we need to do some
|
# your file needs to be set in local time, we need to do some
|
||||||
# hacking around with time. At the moment this requires perl 5
|
# hacking around with time.
|
||||||
# with the standard library.
|
|
||||||
|
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
zmodload zsh/datetime
|
||||||
|
|
||||||
local time gmtime loctime
|
local time gmtime loctime year mon mday hr min sec y tmpdate
|
||||||
|
local -i days_since_epoch
|
||||||
|
|
||||||
if [[ -n $3 ]]; then
|
if [[ -n $3 ]]; then
|
||||||
time=$3
|
time=$3
|
||||||
|
@ -21,25 +22,22 @@ else
|
||||||
fi
|
fi
|
||||||
[[ -z $time ]] && return 1
|
[[ -z $time ]] && return 1
|
||||||
|
|
||||||
# Now's the real *!@**!?!. We have the date in GMT and want to turn
|
year=$time[1,4]
|
||||||
# it into local time for touch to handle. It's just too nasty
|
mon=$time[5,6]
|
||||||
# to handle in zsh; do it in perl.
|
mday=$time[7,8]
|
||||||
if perl -mTime::Local -e '($file, $t) = @ARGV;
|
hr=$time[9,10]
|
||||||
$yr = substr($t, 0, 4) - 1900;
|
min=$time[11,12]
|
||||||
$mon = substr($t, 4, 2) - 1;
|
sec=$time[13,14]
|
||||||
$mday = substr($t, 6, 2) + 0;
|
|
||||||
$hr = substr($t, 8, 2) + 0;
|
|
||||||
$min = substr($t, 10, 2) + 0;
|
|
||||||
$sec = substr($t, 12, 2) + 0;
|
|
||||||
$time = Time::Local::timegm($sec, $min, $hr, $mday, $mon, $yr);
|
|
||||||
utime $time, $time, $file and return 0;' $1 $time 2>/dev/null; then
|
|
||||||
print "Setting time for $1 failed. Need perl 5." 2>1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If it wasn't for the GMT/local time thing, it would be this simple.
|
#count the number of days since epoch without the current day
|
||||||
#
|
for y in {1970..$(( $year - 1))}; do
|
||||||
# time="${time[1,12]}.${time[13,14]}"
|
strftime -s tmpdate -r "%Y/%m/%d" ${y}/12/31
|
||||||
#
|
days_since_epoch+=$(strftime "%j" $tmpdate)
|
||||||
# touch -t $time $1
|
done
|
||||||
|
strftime -s tmpdate -r "%Y/%m/%d" $year/$mon/$(( $mday - 1 ))
|
||||||
# }
|
days_since_epoch+=$(strftime "%j" $tmpdate)
|
||||||
|
# convert the time in number of seconds (this should be equivalent to timegm)
|
||||||
|
time=$(( $sec + 60 * ( $min + 60 * ($hr + 24 * $days_since_epoch)) ))
|
||||||
|
#Convert it back to CCYYMMDDhhmmSS
|
||||||
|
strftime -s time "%Y%m%d%H%M%S" ${EPOCHSECONDS}
|
||||||
|
touch -t ${time[1,12]}.${time[13,14]} $1
|
||||||
|
|
Loading…
Reference in a new issue