Actionscript 3 Flash中的条件日期格式
我正在按以下方式格式化空中移动项目中的当前日期:Actionscript 3 Flash中的条件日期格式,actionscript-3,flash,air,Actionscript 3,Flash,Air,我正在按以下方式格式化空中移动项目中的当前日期: var dateFormatter:DateTimeFormatter = new DateTimeFormatter( Capabilities.language ); dateFormatter.setDateTimePattern("EEEE d"); trace(dateFormatter.format(date)); 这很完美,但由于我有宽度限制(只能显示12个字符),问题是在某些语言(如葡萄牙语)中,EEEE格式返回Segunda
var dateFormatter:DateTimeFormatter = new DateTimeFormatter( Capabilities.language );
dateFormatter.setDateTimePattern("EEEE d");
trace(dateFormatter.format(date));
这很完美,但由于我有宽度限制(只能显示12个字符),问题是在某些语言(如葡萄牙语)中,EEEE格式返回Segunda feria
,这意味着字符数将为16个(包括天数)
有没有一种方法可以将条件格式设置为EEEE不能超过10个字符?(即:始终使用EEE,但如果超过12个字符,则显示EEE)尝试以下操作:
var str_tmp: String ="";
var dateFormatter :DateTimeFormatter = new DateTimeFormatter( Capabilities.language );
dateFormatter.setDateTimePattern("EEEE d");
//# check for larger than 12 chars
str_tmp = dateFormatter.format(date);
if ( str_tmp.length > 12 ) { dateFormatter.setDateTimePattern("EEE d"); }
trace(dateFormatter.format(date));
那么您希望它显示为什么?一种方法是收集字符串长度,并使用dateString.splice(12,dateString.length)将其缩短。在那里,我添加了一个我请求的示例。