文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>人事资料修复

人事资料修复

时间:2005-01-19  来源:emailwht

昨天人事主机的控制器时间给初始化了,给调到1970年,时间又与标准时间相差6小时30分左右,日期好改一些,但时间就不好办了,幸而有网上的朋友帮忙,有如下代码要吧改过来了,原来资料

"08686:20050117:050740:4:02:1:051:00000000"
"06665:20050117:051919:4:02:1:051:00000000"
"07440:20050117:051923:4:02:3:051:00000000"
"10724:20050117:051959:4:02:3:051:00000000"
"05545:20050117:052000:4:01:4:051:00000000"
"08301:20050117:052007:4:02:3:051:00000000"
修改code:

修改后为:

"08686:20050117:113740:4:02:1:051:00000000"
"06665:20050117:114919:4:02:1:051:00000000"
"07440:20050117:114923:4:02:3:051:00000000"
"10724:20050117:114959:4:02:3:051:00000000"
"05545:20050117:115000:4:01:4:051:00000000"
"08301:20050117:115007:4:02:3:051:00000000"

waker:

tzs=$TZ
export TZ=UTC0
awk  'BEGIN{FS=":";OFS=":"}{a=$3;
a=gensub(/(..)(..)(..)/, "1970 01 01 1 2 3 0", "g",a);
a=mktime(a)+mktime("1970 01 01 06 30 00 0");
print $1,$2,strftime("%H%M%S", a),$4,$5,$6,$7,$8;}'  yourfile
export TZ=$tzs


tianci3982730:

代码:
awk -F[:] '{"date -d " """$2" "substr($3,1,2)":"substr($3,3,2)":"substr($3,5,2)" $(date +%Z) +$(echo $((06*3600+30*60)))second " """ " +%Y%m%d:%H%M%S"|getline b ;print $1":"b":"$4":"$5":"$6":"$7":"$8 }' file

linux下测试通过
你也可直接把$(echo $((06*3600+30*60)))写成23400了速度更快
也可直接把$(date +%Z)写成你的时区了如CST速度更快了
当然也可把这些放在BEGIN里了。
如下
代码:
awk -F[:] '{"date -d " """$2" "substr($3,1,2)":"substr($3,3,2)":"substr($3,5,2)" CST +23400second " """ " +%Y%m%d:%H%M%S"|getline b ;print $1":"b":"$4":"$5":"$6":"$7":"$8 }' file

shaoping0330:

#!/bin/bash
# 0 successd
# 2 the file is not exist
# 1 Usage is error
# 3 bak file is exist
if [ ! -f $1 ];then
echo "${1} : The file is not exist ,please try later!"
exit 2
fi

if [ $# -ne 1 ];then
echo "USAGE: $0 file"
exit 1
fi

if [ -f ${1}.bak ];then
echo "${1}.bak : the bak file is exist,please delete at first"
exit 3
fi

line=$(wc -l ${1}|awk '{print $1}')

i=1
while [ $i -lt $line ];do
my_time=$(awk -F":" '{print $3}' ${1} |sed -n "$i"'p')
my_hour=${my_time:0:2}
my_minute=${my_time:2:2}
my_second=${my_time:4:2}

# my_second=$((my_second+00))
my_minute=$((my_minute+30))
my_hour=$((my_hour+06))

# if [[ my_second -gt 60 ]];then
# my_second=$((my_second-60))
# my_minute=$((my_minute+1))
# fi
# if [[ my_second -lt 10 ]];then
# my_second=0${my_second}
# fi

if [[ my_minute -gt 60 ]];then
my_minute=$((my_minute-60))
my_hour=$((my_hour+1))
fi

if [[ my_minute -lt 10 ]];then
my_minute=0${my_minute}
fi

my_time=${my_hour}${my_minute}${my_second}
sed -n "${i} s/:[0-9]{6}:/:${my_time}:/p" ${1} >> ${1}.bak

((i++))
done

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载