求一个在Linux判断当前是否为周末的算法,感激不尽!
在google和github找了半天没找到啊,可能是方法不对:(
求一个在Linux判断当前是否为周末的算法,感激不尽!
在google和github找了半天没找到啊,可能是方法不对:(
|
jarlyynApr 14, 2015
1
不提语言么……
很多脚本语言都可以直接啊 |
|
lululauApr 14, 2015
2
`[ $(date '+%u') -gt 5 ] && echo weekends`
|
|
windalexApr 14, 2015
3
shell:date +%w
算法: https://zh.wikipedia.org/wiki/%E8%94%A1%E5%8B%92%E5%85%AC%E5%BC%8F |
|
stackpopApr 14, 2015
4
用 c语言的话,已知1900-01-01是星期一,算一下天数 mod 7就出来了。
用 Python, shell, perl 之类的语言就更简单了 |
|
5
C 语言版本:用 time(2) 获取当前时间 time_t,localtime(3) 把 time_t 转换成 struct tm, struct tm 中有 tm_wday 字段表示星期
|
|
7
同时感谢各位热心的网友们:)
|
|
dingyaguang117Apr 14, 2015 via iPhone
8
请搜索 蔡勒公式
|
|
xylophone21Apr 14, 2015
9
xx脚本可以 ==> 翻脚本语音的源代码 ==> 挖出C代码
|