mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge pull request #193 from Icinga/feature/adds_ms_support_for_get_icinga_unix_time
Feature: Add optional support for adding milliseconds to Get-IcingaUnixTime Adds support to add milliseconds to the result of `Get-IcingaUnixTime` which might come in handy for more time depending tasks.
This commit is contained in:
commit
12687bd30a
2 changed files with 10 additions and 0 deletions
|
|
@ -13,6 +13,8 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
|
||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
||||||
|
* [#193](https://github.com/Icinga/icinga-powershell-framework/pull/193) Adds optional support for adding milliseconds to `Get-IcingaUnixTime` with the `-Milliseconds` argument for more detailed time comparison
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
* [#188](https://github.com/Icinga/icinga-powershell-framework/pull/188) Removes hardcoded zones `director-global` and `global-zones` which were always set regardless of user specification. This fix will ensure the user has the option to add or not add these zones
|
* [#188](https://github.com/Icinga/icinga-powershell-framework/pull/188) Removes hardcoded zones `director-global` and `global-zones` which were always set regardless of user specification. This fix will ensure the user has the option to add or not add these zones
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
function Get-IcingaUnixTime()
|
function Get-IcingaUnixTime()
|
||||||
{
|
{
|
||||||
|
param(
|
||||||
|
[switch]$Milliseconds = $FALSE
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($Milliseconds) {
|
||||||
|
return ([int64](([DateTime]::UtcNow) - (Get-Date '1/1/1970')).TotalMilliseconds / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
return [int][double]::Parse(
|
return [int][double]::Parse(
|
||||||
(Get-Date -UFormat %s -Date (Get-Date).ToUniversalTime())
|
(Get-Date -UFormat %s -Date (Get-Date).ToUniversalTime())
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue