shell日期处理函数

shell日期处理函数

ID:41394550

大小:57.75 KB

页数:16页

时间:2019-08-24

shell日期处理函数_第1页
shell日期处理函数_第2页
shell日期处理函数_第3页
shell日期处理函数_第4页
shell日期处理函数_第5页
资源描述:

《shell日期处理函数》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、shell日期处理函数#######################################SHELLdatefunction##1:(check_leap)todeterminewhetheraleapyear##2:getsthemaximumdategetmondays(#)JuneThedateof#3:(check_date)#checkformat#4:(getbeforedate)#datebacktoyesterday#5:(getnextdate)#dateofreturntomorrow#6:returnsthemonthenddateYYYYMMDDget_c

2、ur_date()#7:returnsYYYYMMgetcurmonth()inthemonthofthemonth#8:returnslastmonth,sdateYYYYMMDD,getlastdate()#9:returnsYYYYMMget_last_month()lastmonth#######################################Todeterminewhetheraleapyear##input:year44-丄〃丄〃〃X?〃〃#output:true,faseCheck_leap(){Y二'exptsubstr$114'Rl='expr$Y%4R2

3、二'expt$Y%100'R3二'expt$Y%400'If[$rl,-eq,0,-a,$r2,-ne,0,-o,$r3,-eq,0]ThenFRUN二〃tme〃〃ElseFRUN二"false"FiEcho$FRUN#getsthemaximumdatemonthMethods1#Get_mon_days(){Y='exprsubstr$114M二'exptsubstr$152'Case〃$『in01

4、03

5、05

6、07

7、08

8、10

9、12)days二31;;04

10、06

11、09

12、ll)days二30;;02)_tmpStr='checkleap〃$Y"#'todeterminewhethera

13、leapyearIf[[$_tmpStr'二'truethen#leapyearDays二29ElseDays=28Fi••VV*)Days二0••ESAC环氧氯丙烷o$b}Dearsirsre#getsthemaximumdatemonthMethods2#Get_mon_days2()Y二exprsubstr$114exprsubstr$152'#fromtheendofthemonthwhenthelastdayAa='cal$M$Y'#calendarDays二'echo$aaawk'{print$NF}Echo$daysCheckthedate#format(forexample

14、:20090227)#returnstatus($0?)1illegallegitimateCheckdate(){#checkincomingoneparameter]1]&&echol&&exit1-ne$#Check#stringlength_lenSti-'exprlength〃$1"?[$_lenStr,-ne8]&&echol&&exit1#checkwhethertheinputisnotthebeginningofthe0digital_tmpStr='echo〃$1〃grep[0-9]*$〃,[-z,〃$_tinpStT〃]&&echol&&exit1Y二exprsubs

15、tr$114M二exprsubstr$152'D二exprsubstr$172'#checkin-It1,-o,$M,-gt12]&&echol&&exit1#takethenumberofdaysofthemonthDays='get_mon_days〃$Y$M〃Checkon#]〃$D〃,-It1,-o,$D,-gt,$days,&&echol&&exit1Echo0}##returndateyesterdayGet_before_date(){Y='exprsubstr$114exprsubstr$152'D二exprsubstr$172'A#01OctobercaseIf[[$D]

16、-eq01ThenIf[[$M]-eq01ThenA01year#Sept.01caseFromtheendoflastyear#date(December31st)YY二expr$Y-1Be_date=〃${YY}1231〃〃Else#fromtheendofMM二expt$M-1MM二'printf〃%02d〃Dad二'getmondayslastmonthdate〃$Y$MM〃Be_date=〃$Y$MM$dad〃

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。