Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 Flash中的条件日期格式_Actionscript 3_Flash_Air - Fatal编程技术网

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)将其缩短。在那里,我添加了一个我请求的示例。