Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: freestyler on June 06, 2009, 04:22:24 pm
-
I am finishing a new script but I can't get it to work on non-English platforms. I want to get the number of day of week (Monday = 1, Tuesday = 2, ..., Sunday = 7); as for now, I have the following:
function dayofweek(day: string): byte;
begin
result := 0;
case day of
'Mon': result := 1;
'Tue': result := 2;
'Wed': result := 3;
'Thu': result := 4;
'Fri': result := 5;
'Sat': result := 6;
'Sun': result := 7;
end;
end;
{
calling this function by:
today := dayofweek(formatdate('ddd'));
}
It works perfectly when on English-language server, but on any other it returns 0.
Is there any way to get the number of day of week without language incompabilities?
-
maybe there's some function to check what language has the computer, and depending on which one has, it executes in a different way?
-
maybe there's some function to check what language has the computer
It's not necessary, it's just a matter of day names I put into 'case day of', but it doesn't work all the time (for example, Polish Wednesday is Środa, and that character is unreadable by scripting engine). I am looking for a function that wouldn't use day names for that.
-
you could try turning the name of the day into a Byte... is that possible?
-
Look at the script in first post and answer yourself. The trick is not to use the name of day at all.
-
FormatDate gets data from pc, so I don't think its possible to get it in english only.
Quote from some program: 'Today is 27 Maj 2009'
-
It's not necessary, it's just a matter of day names I put into 'case day of', but it doesn't work all the time (for example, Polish Wednesday is Środa, and that character is unreadable by scripting engine). I am looking for a function that wouldn't use day names for that.
You can use ascii numbers to replace certain characters. In this case 'Środa' would become:
s : string;
s := #346+'roda';
At least according to this site (http://webdesign.about.com/od/localization/l/blhtmlcodes-pl.htm).
If that doesn't work you could also save all the days in a file and read those as string, that way you don't have to use these characters in your code.
However, the most elegant solution is to forget about names of days at all (supose someone with a chinese platform tries your script). You could try to find(google) or create a formula that will extract the daynumber out of the three date numbers yy mm dd. Hmm.. maybe i'll break my head around that one, might be interesting.
edit:click (http://stason.org/TULARC/society/calendars/2-15-1-Is-there-a-formula-for-calculating-the-Julian-day-nu.html)
-
edit:click (http://stason.org/TULARC/society/calendars/2-15-1-Is-there-a-formula-for-calculating-the-Julian-day-nu.html)
Thank you, it works! :)
-
or just do:
FormatDate('d');
// 1000 times easier <.<
-
or just do:
FormatDate('d');
// 1000 times easier <.<
ouch.. :p
-
Um... No? FormatDate('d') returns day of month, not day of week.