PoshCode Archive  Artifact [97f6dd74b8]

Artifact 97f6dd74b8d639fbba43005dce9808f69d6c8352cc954622ff846969090ef953:

  • File Get-EasterEastern.ps1 — part of check-in [5471048556] at 2018-06-10 13:27:04 on branch trunk — Calculates the Julian Easter date in the Julian calendar for a given year. (user: michaelvdnest size: 1464)

# encoding: ascii
# api: powershell
# title: Get-EasterEastern
# description: Calculates the Julian Easter date in the Julian calendar for a given year.
# version: 0.1
# type: function
# author: michaelvdnest
# license: CC0
# function: Get-EasterEastern
# x-poshcode-id: 3526
# x-archived: 2012-07-20T07:46:38
# x-published: 2012-07-18T02:24:00
#
#
function Get-EasterEastern {
	Param(
		[Parameter(Mandatory=$true)]
        [int] $Year
	)
	
	$a = $Year % 4
	
	$b = $Year % 7
	
	$c = $Year % 19 	
	
	$d = ((19 * $c) + 15) % 30 	
	
	$e1 = -$d #here because powershell is picking up - (subtraction operator) as incorrect toekn
	$e = ((2 * $a) + (4 * $b) + $e1 + 34) % 7 	
	
	$month = [Math]::Floor(($d + $e + 114) / 31)
	
	$day = (($d + $e + 114) % 31) + 1 	

	$cal = New-Object -TypeName System.Globalization.JulianCalendar
	
	New-Object -TypeName System.DateTime -ArgumentList $Year,$month,$day,$cal
	
	<#
		.SYNOPSIS
			Calculates the Julian Easter date in the Julian calendar for a given year.

		.DESCRIPTION
			Calculates the Julian Easter date in the Julian calendar for a given year. This is not the Gregorian Easter now used by Western churches. Algorithm sourced from http://en.wikipedia.org/wiki/Computus, Meeus Julian algorithm.

		.PARAMETER Year
			The year to calculate easter for.

		.EXAMPLE
			PS C:\> Get-EasterEastern 2017

		.INPUTS
			System.Int32

		.OUTPUTS
			System.DateTime
	#>
}