- 论坛徽章:
- 307
|
本帖最后由 sunzhiguolu 于 2017-07-28 15:36 编辑
- function Parse{
- [int] $h, [int] $m, [int] $s = $args[0] -split ":"
- $m += [int] ($s / 60)
- $s = $s % 60
- $h += [int] ($m / 60)
- $m = $m % 60
- return "{0:d2}:{1:d2}:{2:d2}" -f $h, $m, $s
- }
- @{na = "01:00:02"; nb = "02:30:10"}, @{na = "00:00:65"; nb = "00:01:01"},
- @{na = "55:43:11"; nb = "55:42:71"} | foreach {
- $a = Parse $_.na
- $b = Parse $_.nb
- if($a -eq $b){
- $cmp = "=="
- }elseif($a -gt $b){
- $cmp = ">"
- }else{
- $cmp = "<"
- }
- Write-Host $_.na $cmp $_.nb
- }
复制代码
![]()
- function Parse{
- [int] $h, [int] $m, [int] $s = $args[0] -split ":"
- return ($h * 60 + $m) * 60 + $s
- }
复制代码
|
|