项目作者: Quake4

项目描述 :
Human Interval Time Converter
高级语言: PowerShell
项目地址: git://github.com/Quake4/HumanInterval.git
创建时间: 2017-10-22T08:11:27Z
项目社区:https://github.com/Quake4/HumanInterval

开源协议:GNU General Public License v3.0

下载


Human Interval Time Converter

Convert time human interval to TimeStamp

Example of time interval conversion

  • “1 hour 30 sec”
  • “1 day 12 hours 30 minutes”
  • “40min 300seconds”
  • “60 seconds”

Known time measurements

  • seconds, second, secs, sec
  • minutes, minute, mins, min
  • hours, hour
  • days, day
  • weeks, week (since v1.1)

Include

  1. . .\HumanInterval.ps1

Usage

Example

  1. [TimeStamp] $ts = [HumanInterval]::Parse("30 sec")
  2. $secs = [HumanInterval]::Parse("5 min 30 sec").TotalSeconds
  3. $mins = (Get-Interval "2 hour 15 min").TotalMinutes
  4. $mins = (Get-Interval -Interval "1day 6hours 45 mins").TotalMinutes

TimeSpan properties

  • Days - Gets the days component of the time interval.
  • Hours - Gets the hours component of the time interval.
  • Minutes - Gets the minutes component of the time interval.
  • Seconds - Gets the seconds component of the time interval.
  • TotalDays - Gets the value expressed in whole and fractional days.
  • TotalHours - Gets the value expressed in whole and fractional hours.
  • TotalMinutes - Gets the value expressed in whole and fractional minutes.
  • TotalSeconds - Gets the value expressed in whole and fractional seconds.

Requirements

PowerShell version >= 5.0

License

GPL-3.0