| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:assets="assets.*" width="100%" height="100%" > |
| |
| <fx:Script> |
| <![CDATA[ |
| import flash.globalization.DateTimeStyle; |
| |
| import mx.core.mx_internal; |
| import mx.events.FlexEvent; |
| use namespace mx_internal; |
| |
| private static const WEEKDAY_LABELS:Vector.<String> = new <String> |
| ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", |
| "Saturday"]; |
| private static const MONTH_LABELS:Vector.<String> = new <String> |
| ["January", "February", "March", "April", "May", "June", |
| "July", "August", "September", "October", "November", "December"]; |
| |
| public function getExpectedValueofDate3(dateStyle:String, timeStyle:String,dateTime:Date):String |
| { |
| return returnDate(dateTime,dateStyle,timeStyle) + returnSpace(dateTime,dateStyle,timeStyle) + returnTime(dateTime,dateStyle,timeStyle); |
| } |
| |
| private function returnDate(dateTime:Date, dateStyle:String, timeStyle:String):String |
| { |
| var returnDateStr:String = ''; |
| if(dateStyle =='long' || dateStyle =='medium') |
| { |
| returnDateStr = (WEEKDAY_LABELS[dateTime.getUTCDay()] + ","+" " |
| + MONTH_LABELS[dateTime.getUTCMonth()])+" " |
| + dateTime.getUTCDate() + ","+" " |
| + dateTime.getUTCFullYear(); |
| } |
| else if(dateStyle == 'short') |
| { |
| returnDateStr = (dateTime.getUTCMonth() + 1) + "/" |
| + dateTime.getUTCDate() + "/" |
| + dateTime.getUTCFullYear(); |
| } |
| else |
| returnDateStr = ''; |
| return returnDateStr; |
| } |
| private function returnTime(dateTime:Date, dateStyle:String, timeStyle:String):String |
| { |
| var returnTimeStr:String=''; |
| if(timeStyle =='long' || timeStyle =='medium') |
| { |
| var localTime:String = getUSClockTime(dateTime.getUTCHours(), dateTime.getUTCMinutes()); |
| var seconds:Number = dateTime.getUTCSeconds(); |
| |
| returnTimeStr = localTime + ":" + doubleDigitFormat(seconds) + " " |
| + formatAMPM(dateTime); |
| } |
| else if(timeStyle == 'short') |
| { |
| returnTimeStr = getUSClockTime(dateTime.getUTCHours(), dateTime.getUTCMinutes())+ " " + formatAMPM(dateTime); |
| } |
| else |
| returnTimeStr = ''; |
| return returnTimeStr; |
| } |
| private function returnSpace(dateTime:Date,dateStyle:String, timeStyle:String):String |
| { |
| const fullYearIsNaN:Boolean = dateTime && isNaN(dateTime.fullYear); |
| const oneOfStyleIsNone:Boolean = (dateStyle == DateTimeStyle.NONE) |
| || (timeStyle == DateTimeStyle.NONE); |
| return (fullYearIsNaN || oneOfStyleIsNone) ? "" : " "; |
| } |
| private function getUSClockTime(hrs:uint, mins:uint):String |
| { |
| const minLabel:String = doubleDigitFormat(mins); |
| |
| hrs %= 12; |
| hrs = hrs ? hrs : 12; |
| |
| return hrs + ":" + minLabel; |
| } |
| private function doubleDigitFormat(num:uint):String |
| { |
| return ((num < 10) ? "0" : "") + String(num); |
| } |
| |
| private function formatAMPM(dateTime:Date):String |
| { |
| const hours:Number = dateTime.getUTCHours(); |
| |
| return (hours < 12) ? "AM" : "PM"; |
| } |
| |
| ]]> |
| </fx:Script> |
| <fx:Declarations> |
| <assets:FallbackDTF id="dtFormatterLL" dateStyle="long" timeStyle="long"/> |
| <assets:FallbackDTF id="dtFormatterSM" dateStyle="short" timeStyle="medium"/> |
| <assets:FallbackDTF id="dtFormatterMN" dateStyle="medium" timeStyle="none"/> |
| <assets:FallbackDTF id="dtFormatterNS" dateStyle="none" timeStyle="short"/> |
| <assets:FallbackDTF id="dtFormatterNN" dateStyle="none" timeStyle="none"/> |
| |
| <assets:FallbackDTF id="dtFormatterInvalid"/> |
| |
| <assets:FallbackDTF id="dtFormatterDTP" dateStyle="long" timeStyle="long"/> |
| <assets:FallbackDTF id="dtFormatterDTPLL" dateStyle="long" timeStyle="long"/> |
| <assets:FallbackDTF id="dtFormatterLocale"/> |
| <assets:FallbackDTF id="dtFormatterLocaleLL" dateStyle="long" timeStyle="long"/> |
| </fx:Declarations> |
| |
| </s:Application> |