如何使用 Excel 将公历日期转换为犹太日期?

如何使用 Excel 将公历日期转换为犹太日期?

如何使用 Excel 2007 将公历日期转换为犹太日期?

答案1

可以在以下网站上找到可能会执行您想要的功能:

http://calmath.couprie.org/

(感谢 Google-fu 的帮助)

答案2

Function hebrewdate(thedate)

Dim hebdate As String, monthname As String
Dim hebday As Integer, hebdaylet As String
Dim hebyear As Integer, hebyearlet As String

'   TODO: Return the Hebrew date in UTF-8 (Really useful ?)

'   Gregorian to Jewish date
hebdate = Excel.WorksheetFunction.Text(thedate, "[$-8040D]ddmmmyyyy")

'   Day in the month to number
hebday = Mid(hebdate, 1, 2) * 1

'   Numeric day in the month to Hebrew
hebdaylet = hebdayconv(hebday)

'   Jewish year to number
hebyear = Mid(hebdate, Len(hebdate) - 3, 4) * 1

'   Year to Hebrew
hebyearlet = hebyearconv(hebyear)

'   Extract month name
monthname = Mid(hebdate, 3, Len(hebdate) - 6)

'   Concatenate the final whole Hebrew date
hebrewdate = Chr(254) & hebdaylet & " " & monthname & " " & hebyearlet

End Function


Private Function hebdayconv(hebday As Integer)
'   This function translates an Arabic number to a Hebrew number
Dim un As Integer, dec As Integer
Dim unletter As String, decletter As String, sep As String

'   Extract the units
un = hebday Mod 10

If un > 0 Then
'   Units number to Hebrew
    unletter = Chr(223 + un)
Else
    unletter = ""
End If

'   Extract the tens
If hebday > 9 Then
    decletter = hebdec(hebday \ 10)
    sep = Chr(34)
'   Concatenate the day in month
    hebdayconv = decletter & sep & unletter
Else
    decletter = ""
    sep = Chr(180)
'   Concatenate the day in month and ensure right direction
    hebdayconv = Chr(254) & unletter & Chr(39)
End If

'   Cocatenate the day in month
'   hebdayconv = decletter & sep & unletter

'   Deal with the exceptions
Select Case hebday
    Case 15
        hebdayconv = Chr(232) & sep & Chr(229)
    Case 16
        hebdayconv = Chr(232) & sep & Chr(230)
End Select


End Function

Private Function hebyearconv(hebyear)
Dim un As Integer, dec As Integer
Dim unletter As String, decletter As String, sep As String

'   Year's units
un = hebyear Mod 10

If un = 0 Then
    unletter = ""
    sep = Chr(180)
Else
    unletter = Chr(223 + un)
    sep = Chr(34)
End If

'   Year's tens
dec = (hebyear - 5700) \ 10

decletter = hebdec(dec)
      
'   Tav = 250, Shin = 249
'   TODO: Expand this function beyond the current Jewish century
'   Concatenate the whole Hebrew year
hebyearconv = Chr(250) & Chr(249) & decletter & sep & unletter

End Function


Private Function hebdec(dec)

Select Case dec
    Case 1
        hebdec = Chr(233)
    Case 2
        hebdec = Chr(235)
    Case 3
        hebdec = Chr(236)
    Case 4
        hebdec = Chr(238)
    Case 5
        hebdec = Chr(240)
    Case 6
        hebdec = Chr(241)
    Case 7
        hebdec = Chr(242)
    Case 8
        hebdec = Chr(244)
    Case 9
        hebdec = Chr(246)
        
End Select


End Function


'   ISO/IEC 8859-8:1999 Latin/Hebrew Alphabet
'   224 HEBREW LETTER ALEF
'   225 HEBREW LETTER BET
'   226 HEBREW LETTER GIMEL
'   227 HEBREW LETTER DALET
'   228 HEBREW LETTER HE
'   229 HEBREW LETTER VAV
'   230 HEBREW LETTER ZAYIN
'   231 HEBREW LETTER HET
'   232 HEBREW LETTER TET
'   -------------------------------
'   233 HEBREW LETTER YOD
'   *** 234 HEBREW LETTER FINAL KAF
'   235 HEBREW LETTER KAF
'   236 HEBREW LETTER LAMED
'   *** 237 HEBREW LETTER FINAL MEM
'   238 HEBREW LETTER MEM
'   *** 239 HEBREW LETTER FINAL NUN
'   240 HEBREW LETTER NUN
'   241 HEBREW LETTER SAMEKH
'   242 HEBREW LETTER AYIN
'   ** 243  HEBREW LETTER FINAL PE
'   244 HEBREW LETTER PE
'   *** 245 HEBREW LETTER FINAL TSADI
'   246 HEBREW LETTER TSADI
'
'   "   34  QUOTATION MARK
'   '   39  APOSTROPHE
'   254     RIGHT-TO-LEFT MARK


'   The ChrW function returns a String containing the Unicode character
'   The &H preface says that 2588 is a hexadecimal number, which is what you find looking at charmap.
'   d790    HEBREW LETTER ALEF
'   d791    HEBREW LETTER BET
'   d792    HEBREW LETTER GIMEL
'   d793    HEBREW LETTER DALET
'   d794    HEBREW LETTER HE
'   d795    HEBREW LETTER VAV
'   d796    HEBREW LETTER ZAYIN
'   d797    HEBREW LETTER HET
'   d798    HEBREW LETTER TET
'   d799    HEBREW LETTER YOD
'   d79a    HEBREW LETTER FINAL KAF
'   d79b    HEBREW LETTER KAF
'   d79c    HEBREW LETTER LAMED
'   d79d    HEBREW LETTER FINAL MEM
'   d79e    HEBREW LETTER MEM
'   d79f    HEBREW LETTER FINAL NUN
'   d7a0    HEBREW LETTER NUN
'   d7a1    HEBREW LETTER SAMEKH
'   d7a2    HEBREW LETTER AYIN
'   d7a3    HEBREW LETTER FINAL PE
'   d7a4    HEBREW LETTER PE
'   d7a5    HEBREW LETTER FINAL TSADI
'   d7a6    HEBREW LETTER TSADI
'   d7a7    HEBREW LETTER QOF
'   d7a8    HEBREW LETTER RESH
'   d7a9    HEBREW LETTER SHIN
'   d7aa    HEBREW LETTER TAV

相关内容