Skip to content

Commit a1e6a78

Browse files
committed
Adds support for ms on Unix Time
1 parent 7448e98 commit a1e6a78

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)