This way the NSDateFormatter does not work directly to set the correct language.
Code: Select all
Macro CocoaString(NSString)
PeekS(CocoaMessage(0, NSString, "UTF8String"), -1, #PB_UTF8)
EndMacro
Procedure.s GetDateString(Date.s = "")
Protected NSPool, NSDate, NSCurrentLocale, NSLocale, NSDateFormatter, NSString
Protected r1.s
NSPool = CocoaMessage(0, 0, "NSAutoreleasePool new")
NSDateFormatter = CocoaMessage(0, 0, "NSDateFormatter new")
If Date = ""
NSDate = CocoaMessage(0, 0, "NSDate date")
Else
CocoaMessage(0, NSDateFormatter, "setDateFormat:$", @"YYYYMMdd")
NSDate = CocoaMessage(0, NSDateFormatter, "dateFromString:$", @Date)
If Not NSDate
Goto end_function
EndIf
EndIf
NSCurrentLocale = CocoaMessage(0, 0, "NSLocale currentLocale")
NSString = CocoaMessage(0, NSCurrentLocale, "localeIdentifier")
;Debug CocoaString(NSString)
If CocoaString(NSString) = "en_DE"
NSLocale = CocoaMessage(0, 0, "NSLocale localeWithLocaleIdentifier:$", @"de_DE")
Else
NSLocale = NSCurrentLocale
EndIf
CocoaMessage(0, NSString, "release")
CocoaMessage(0, NSDateFormatter, "setLocale:@", @NSLocale)
CocoaMessage(0, NSDateFormatter, "setDateFormat:$", @"EEEE d MMMM YYYY")
NSString = CocoaMessage(0, NSDateFormatter, "stringFromDate:@", @NSDate)
r1 = CocoaString(NSString)
end_function:
CocoaMessage(0, NSDateFormatter, "release")
CocoaMessage(0, NSPool, "release")
ProcedureReturn r1
EndProcedure
Debug GetDateString()
Debug GetDateString("19700101")