Skip to content

Instantly share code, notes, and snippets.

@AspenForester
Last active April 25, 2023 04:01
Show Gist options
  • Save AspenForester/ce5f1e0ccb6920679abd94810662936e to your computer and use it in GitHub Desktop.
Save AspenForester/ce5f1e0ccb6920679abd94810662936e to your computer and use it in GitHub Desktop.
Gets the current local Lunar phased by assuming your location based on your public IP address, which isn't always accurate.
$PublicIP = (Invoke-WebRequest -uri 'https://api.ipify.org?format=json' | convertfrom-json).ip
$GeoInfo = Invoke-WebRequest -Uri "http://www.geoplugin.net/json.gp?ip=$PublicIP" | ConvertFrom-Json
$location = "$($GeoInfo.geoplugin_latitude),$($GeoInfo.geoplugin_longitude)"
$TZ = [TimeZoneInfo]::Local.BaseUtcOffset.Hours
$Now = Get-date -Format M/dd/yyyy
$uri = "http://api.usno.navy.mil/rstt/oneday?date=$Now&coords=$Location&TZ=$TZ"
$Astro = Invoke-WebRequest -Uri $uri | ConvertFrom-Json
$Astro.curphase
# GET https://atlas.microsoft.com/timezone/byCoordinates/json?api-version=1.0&options={options}&timeStamp={timeStamp}&transitionsFrom={transitionsFrom}&transitionsYears={transitionsYears}&query={query}
@AspenForester
Copy link
Author

This could also be implemented with Invoke-RestMethod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment