Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Hebrew Date Variables

Aug
1,914
68
Code:
::-----------------------------------------------------------------------------------:
:: HEBREW.BTM  :
::  Set environment variables to reflect the Hebrew Date  :
::  :
:: USAGE: Hebrew.btm [Set] [UnSet]  :
::  :
:: TCC  16.01.45  Windows Vista [Version 6.0.6002]  :
:: TCC Build 45  Windows Vista Build 6002  Service Pack 2  :
:: PowerShell 2.0  :
::  :
:: 2014/04/09 - Joe Caverly  :
::  :
:: While this program offers the UnSet argument to remove  :
::  environment variables that reflect the Hebrew Date, I prefer to  :
::  :
::  SetLocal  :
::  hebrew.btm set  :
::  Do-What-I-Need-To-Do  :
::  EndLocal  :
::  :
::  as this not only removes the environment variables that reflect  :
::  the Hebrew Date, it also removes anything else that I have  :
::  changed in the environment.  :
::  :
::  Reference:  :
::  http://msdn.microsoft.com/en-us/library/system.globalization.hebrewcalendar.aspx :
::-----------------------------------------------------------------------------------:
@echo off
iff %# eq 0 then
  echo USAGE: Hebrew.btm [Set] [UnSet]
  quit
endiff

iff %1 eq Set then
  set _year=%@execstr[powershell -noprofile -Command "& { $hebrew=new-object system.globalization.hebrewcalendar; $TheDate=Get-Date; $Hebrew.GetYear($TheDate)}"]
  set _leapyear=%@execstr[powershell -noprofile -Command "& { $hebrew=new-object system.globalization.hebrewcalendar; $TheDate=Get-Date; $Hebrew.IsLeapYear(%_year)}"]
  set _day=%@execstr[powershell -noprofile -Command "& { $hebrew=new-object system.globalization.hebrewcalendar; $TheDate=Get-Date; $Hebrew.GetDayOfMonth($TheDate)}"]
  set _doy=%@execstr[powershell -noprofile -Command "& { $hebrew=new-object system.globalization.hebrewcalendar; $TheDate=Get-Date; $Hebrew.GetDayOfYear($TheDate)}"]

  set _dowf=%@execstr[powershell -noprofile -Command "& { $hebrew=new-object system.globalization.hebrewcalendar; $TheDate=Get-Date; $Hebrew.GetDayOfWeek($TheDate)}"]
  switch %_dowf
  case Sunday
    set _dowf=Yom Rishon
   case Monday
    set _dowf=Yom Sheni
   case Tuesday
    set _dowf=Yom Shlishi
   case Wednesday
    set _dowf=Yom Reviee
   case Thursday
    set _dowf=Yom Chamishi
   case Friday
    set _dowf=Yom Shishi
   case Saturday
    set _dowf=Shabat
  endswitch
 
  set _month=%@execstr[powershell -noprofile "& { $hebrew=new-object system.globalization.hebrewcalendar; $TheDate=Get-Date; $Hebrew.GetMonth($TheDate)}"]
  switch %_month
    case 1
      set _monthf=Tishrei
    case 2
      set _monthf=Cheshvan
    case 3
      set _monthf=Kislev
    case 4
      set _monthf=Tevet
    case 5
      set _monthf=Shevat
    '
    ' Take into account Leap Years
    '
    case 6
      Iff %_leapyear eq True Then
        set _monthf=Adar Alef
      Else
        set _monthf=Adar
      EndIff
    case 7
      Iff %_leapyear eq True Then
        set _monthf=Adar Beit
      Else
        set _monthf=Nissan
      EndIff
    case 8
      Iff %_leapyear eq True Then
        set _monthf=Nissan
      Else
        set _monthf=Iyar
      EndIff
    case 9
      Iff %_leapyear eq True Then
        set _monthf=Iyar
      Else
        set _monthf=Sivan
      EndIff
    case 10
      Iff %_leapyear eq True Then
        set _monthf=Sivan
      Else
        set _monthf=Tamuz
      EndIff
    case 11
      Iff %_leapyear eq True Then
        set _monthf=Tamuz
      Else
        set _monthf=Av
      EndIff
    case 12
      Iff %_leapyear eq True Then
        set _monthf=Av
      Else
        set _monthf=Elul
      EndIff
    case 13
      set _monthf=Elul
  EndSwitch
endiff

iff %1 eq UnSet then
  if defined _year unset _year
  if defined _leapyear unset _leapyear
  if defined _day  unset _day
  if defined _doy  unset _doy
  if defined _dowf unset _dowf
  if defined _month unset _month
  if defined _monthf unset _monthf
endiff
 
Back
Top