Skip to content

Commit 12687bd

Browse files
authored
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.
2 parents 7448e98 + a1e6a78 commit 12687bd

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

doc/31-Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1313

1414
### Enhancements
1515

16+
* [#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
17+
1618
### Bugfixes
1719

1820
* [#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

lib/core/tools/Get-IcingaUnixTime.psm1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
function Get-IcingaUnixTime()
22
{
3+
param(
4+
[switch]$Milliseconds = $FALSE
5+
);
6+
7+
if ($Milliseconds) {
8+
return ([int64](([DateTime]::UtcNow) - (Get-Date '1/1/1970')).TotalMilliseconds / 1000);
9+
}
10+
311
return [int][double]::Parse(
412
(Get-Date -UFormat %s -Date (Get-Date).ToUniversalTime())
513
);

0 commit comments

Comments
 (0)