Option Explicit
'See http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx for meaning of various constants.
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, _
ByVal LCType As Long, _
ByVal lpLCData As String, _
ByVal cchData As Long) As Long
'https://msdn.microsoft.com/en-us/goglobal/bb964664.aspx
Public Const LOCALE_USER_DEFAULT As Long = &H400
Public Const LOCALE_SABBREVLANGNAME As Long = &H3
Public aMonthNames As Variant
Public MonthWord As String
Public aDayNumbers As Variant
Public DayWord As String
Public Const C_caron As Long = &H10D
Sub driver()
MsgBox SpecialDateFormat(DateSerial(2015, 11, 7))
End Sub
Function SpecialDateFormat(Dt As Date)
SetArrays
SpecialDateFormat = _
aMonthNames(Month(Dt) - 1) & _
" " & MonthWord & _
" " & aDayNumbers(Day(Dt) - 1) & _
" " & DayWord
End Function
'https://en.wikipedia.org/wiki/Lithuanian_orthography
'https://en.wikipedia.org/wiki/Latin_Extended-A
'The majority of the Lithuanian alphabet is in the Unicode block C0 controls and basic Latin (non-accented symbols),
'and the rest of the Lithuanian alphabet (aAcCeEeEiIšŠuUuUžŽ) is in the Latin Extended-A.
Private Function SetArrays()
Dim sLang As String
Dim i As Long
sLang = GetInfo(LOCALE_SABBREVLANGNAME)
Select Case sLang
Case "LTH"
aMonthNames = Array("Sausio", "Vasaris", "Kovas", "Balandio", "Geguže", "Birželio", _
"Liepa", "Rugpjutio", "Rugsejio", "Spalio", "Lapkrit" & ChrW(C_caron) & "io", "Gruodio")
MonthWord = "menesio"
aDayNumbers = Array("first", "second", "third", "fourth", "fifth", "sixth", "septinta", _
"eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", _
"sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twenty-first", "twenty-second", _
"twenty-third", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh", _
"twenty-eighth", "twenty-ninth", "thirtieth", "thirty-first")
DayWord = "diena"
Case "ENU"
aMonthNames = Array("January", "February", "March", "April", "May", "June", _
"July", "Auguet", "September", "October", "November", "December")
MonthWord = "month"
aDayNumbers = Array("first", "second", "third", "fourth", "fifth", "sixth", "seventh", _
"eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", _
"sixteenth", "seventeenth", "eighteenth", "nineteenth", "twentieth", "twenty-first", "twenty-second", _
"twenty-third", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh", _
"twenty-eighth", "twenty-ninth", "thirtieth", "thirty-first")
DayWord = "day"
Case Else
MsgBox "Oops"
End Select
End Function
Private Function GetInfo(ByVal lInfo As Long) As String
Dim Buffer As String
Dim ret As String
Buffer = String$(256, 0)
ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
If ret > 0 Then
GetInfo = Left$(Buffer, ret - 1)
Else
GetInfo = vbNullString
End If
lbl_Exit:
Exit Function
End Function