
Philip Saltskog
Top achievements
Rank 2
Philip Saltskog
asked on 07 May 2009, 12:18 PM
Hello!
I get the date from get_start in a javascript function, but I get English format there? I have set Culture to Sweden.
I get the date from get_start in a javascript function, but I get English format there? I have set Culture to Sweden.
function ViewSubjectIfNotClickable(sender, eventArgs) { |
var currentlySelectedAppoitment = eventArgs.get_appointment(); |
var AllowEdit = currentlySelectedAppoitment.get_allowEdit(); |
if (AllowEdit == false) { |
// alert(currentlySelectedAppoitment.get_subject()); |
// alert(currentlySelectedAppoitment.get_start()); |
var myData = currentlySelectedAppoitment.get_start() + "<br><br>" + currentlySelectedAppoitment.get_subject(); |
customFunctionCreateWindow(false, 300, 150, 300, 150, myData); |
} |
} |
Can I get the date format in Swedish like I get it in the code behind?
/Thanks
/Thanks
3 Answers, 1 is accepted
0
Hi Philip,
The datetime object on the client is formatted by the browser.
The good news is that you can workaround this problem using the following blog post:
http://blog.mastykarz.nl/javascript-date-formatting-net-style/
I downloaded the Imtech.Utils.js file from there and tried the following for Dutch culture which worked nicely:
You will have to translate the strings to Sweedish.
Greetings,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The datetime object on the client is formatted by the browser.
The good news is that you can workaround this problem using the following blog post:
http://blog.mastykarz.nl/javascript-date-formatting-net-style/
I downloaded the Imtech.Utils.js file from there and tried the following for Dutch culture which worked nicely:
<script type="text/javascript"> |
var Imtech = Imtech || {}; |
Imtech.Utils = { |
date: { |
"1033": { |
monthsLong: ["January", "Febraury", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], |
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], |
daysLong: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], |
daysShort: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], |
patterns: { |
"d": "M/d/yyyy", |
"D": "dddd, MMMM dd, yyyy", |
"f": "dddd, MMMM dd, yyyy H:mm tt", |
"F": "dddd, MMMM dd, yyyy H:mm:ss tt", |
"g": "M/d/yyyy H:mm tt", |
"G": "M/d/yyyy H:mm:ss tt", |
"m": "MMMM dd", |
"o": "yyyy-MM-ddTHH:mm:ss.fff", |
"s": "yyyy-MM-ddTHH:mm:ss", |
"t": "H:mm tt", |
"T": "H:mm:ss tt", |
"U": "dddd, MMMM dd, yyyy HH:mm:ss tt", |
"y": "MMMM, yyyy" |
}, |
tt: { |
"AM": "AM", |
"PM": "PM" |
}, |
clockType: 12 |
}, |
"1043": { |
monthsLong: ["januari", "febrauri", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"], |
monthsShort: ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"], |
daysLong: ["maandag", "dinsdag", "woensdag", "donderdag", "vridag", "zaterdag", "zondag"], |
daysShort: ["ma", "di", "wo", "do", "vr", "za", "zo"], |
patterns: { |
"d": "d-M-yyyy", |
"D": "dddd d MMMM yyyy", |
"f": "dddd d MMMM yyyy H:mm", |
"F": "dddd d MMMM yyyy H:mm:ss", |
"g": "d-M-yyyy H:mm", |
"G": "d-M-yyyy H:mm:ss", |
"m": "dd MMMM", |
"o": "yyyy-MM-ddTHH:mm:ss.fff", |
"s": "yyyy-MM-ddTHH:mm:ss", |
"t": "H:mm", |
"T": "H:mm:ss", |
"U": "dddd d MMMM yyyy HH:mm:ss", |
"y": "MMMM, yyyy" |
}, |
tt: { |
"AM": "", |
"PM": "" |
}, |
clockType: 24 |
} |
} |
} |
Date.prototype.format = function(format, locale) { |
var fd = this.toString(); |
var dateFormat = Imtech.Utils.date[locale]; |
if (typeof (dateFormat) !== "undefined") { |
var pattern = typeof (dateFormat.patterns[format]) !== "undefined" ? dateFormat.patterns[format] : format; |
fd = pattern.replace(/yyyy/g, this.getFullYear()); |
fd = fd.replace(/yy/g, (this.getFullYear() + "").substring(2)); |
var month = this.getMonth(); |
fd = fd.replace(/MMMM/g, dateFormat.monthsLong[month].escapeDateTimeTokens()); |
fd = fd.replace(/MMM/g, dateFormat.monthsShort[month].escapeDateTimeTokens()); |
fd = fd.replace(/MM/g, month + 1 < 10 ? "0" + (month + 1) : month + 1); |
fd = fd.replace(/(\\)?M/g, function($0, $1) { return $1 ? $0 : month + 1; }); |
var dayOfWeek = this.getDay(); |
fd = fd.replace(/dddd/g, dateFormat.daysLong[dayOfWeek].escapeDateTimeTokens()); |
fd = fd.replace(/ddd/g, dateFormat.daysShort[dayOfWeek].escapeDateTimeTokens()); |
var day = this.getDate(); |
fd = fd.replace(/dd/g, day < 10 ? "0" + day : day); |
fd = fd.replace(/(\\)?d/g, function($0, $1) { return $1 ? $0 : day; }); |
var hour = this.getHours(); |
if (dateFormat.clockType == 12) { |
if (hour > 12) { |
hour -= 12; |
} |
} |
fd = fd.replace(/HH/g, hour < 10 ? "0" + hour : hour); |
fd = fd.replace(/(\\)?H/g, function($0, $1) { return $1 ? $0 : hour; }); |
var minutes = this.getMinutes(); |
fd = fd.replace(/mm/g, minutes < 10 ? "0" + minutes : minutes); |
fd = fd.replace(/(\\)?m/g, function($0, $1) { return $1 ? $0 : minutes; }); |
var seconds = this.getSeconds(); |
fd = fd.replace(/ss/g, seconds < 10 ? "0" + seconds : seconds); |
fd = fd.replace(/(\\)?s/g, function($0, $1) { return $1 ? $0 : seconds; }); |
fd = fd.replace(/fff/g, this.getMilliseconds()); |
fd = fd.replace(/tt/g, this.getHours() > 12 || this.getHours() == 0 ? dateFormat.tt["PM"] : dateFormat.tt["AM"]); |
} |
return fd.replace(/\\/g, ""); |
} |
String.prototype.escapeDateTimeTokens = function() { |
return this.replace(/([dMyHmsft])/g, "\\$1"); |
} |
function ViewSubjectIfNotClickable(sender, eventArgs) { |
var currentlySelectedAppoitment = eventArgs.get_appointment(); |
var AllowEdit = currentlySelectedAppoitment.get_allowEdit(); |
if (true) { |
// alert(currentlySelectedAppoitment.get_subject()); |
// alert(currentlySelectedAppoitment.get_start()); |
var myData = currentlySelectedAppoitment.get_start().format("D", 1043) + "<br><br>" + currentlySelectedAppoitment.get_subject(); |
alert(myData); |
} |
} |
You will have to translate the strings to Sweedish.
Greetings,
Peter
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Philip Saltskog
Top achievements
Rank 2
answered on 18 May 2009, 08:20 AM
Nice one! Thanks!
Could this also affect the name of the day? Now we have only two letters instead of three as "Må,Ti,On,To,Fr,Lö,Sö".
Thanks again :)
Thanks again :)
0
Hello,
You should be able to adjust the individual day names by changing the values for daysShort:
// ...
daysShort: ["ma", "di", "wo", "do", "vr", "za", "zo"],
// ...
Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You should be able to adjust the individual day names by changing the values for daysShort:
// ...
daysShort: ["ma", "di", "wo", "do", "vr", "za", "zo"],
// ...
Sincerely yours,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.