New-SnowflakeLite.ps1


<#PSScriptInfo
 
.VERSION 1.1.0
 
.GUID 60c7add9-8abb-413c-aadc-9f3643e1e56e
 
.AUTHOR Tigran TIKSN Torosyan
 
.COMPANYNAME
 
.COPYRIGHT Copyright © Tigran TIKSN Torosyan
 
.TAGS
 
.LICENSEURI
 
.PROJECTURI
 
.ICONURI
 
.EXTERNALMODULEDEPENDENCIES
 
.REQUIREDSCRIPTS
 
.EXTERNALSCRIPTDEPENDENCIES
 
.RELEASENOTES
 
 
.PRIVATEDATA
 
#>


#Requires -Module PSFramework

<#
 
.DESCRIPTION
 Creates Integer Snowflake based on seconds
 
#>

[CmdletBinding()]
param(
    [switch]$CopyToClipboard
)


$epochStarts = Get-Date -Year 2024 -Month 1 -Day 1 -Hour 0 -Minute 0 -Second 0 -Millisecond 0
$epochStartsString = $epochStarts | Get-Date -Format 'u'
Write-PSFMessage -Level Verbose -Message "Epoch starts $epochStartsString"

$epochEnds = $epochStarts + [System.TimeSpan]::FromSeconds([System.Int32]::MaxValue)
$epochEndsString = $epochEnds | Get-Date -Format 'u'
Write-PSFMessage -Level Verbose -Message "Epoch ends $epochEndsString"
$instantNow = Get-Date
$instantNowString = $instantNow | Get-Date -Format 'u'
Write-PSFMessage -Level Verbose -Message "Now is $instantNowString"

$passed = $instantNow - $epochStarts
$passedTotalSeconds = [int]$passed.TotalSeconds

Write-PSFMessage -Level Verbose -Message "Total $passedTotalSeconds Seconds passed"
if ( $CopyToClipboard) {
    $passedTotalSeconds | Set-Clipboard
    Write-PSFMessage -Level Important -Message "Copied $passedTotalSeconds to Clipboard"
}

Write-Output $passedTotalSeconds