forked from: forked from: 1桁の月や日を0Xの形に

by Nicolas forked from forked from: 1桁の月や日を0Xの形に (diff: 17)
一の位が0になるときの対策のため、100で割るのを100足すのに変えてみました。
♥0 | Line 19 | Modified 2011-02-11 16:21:50 | MIT License
play

ActionScript3 source code

/**
 * Copyright Nicolas ( http://wonderfl.net/user/Nicolas )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8EoF
 */

// forked from Nicolas's forked from: 1桁の月や日を0Xの形に
// forked from zahir's 1桁の月や日を0Xの形に
package {
    import flash.text.TextField;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            var d:Date = new Date();
            var month:String = String( (d.getMonth() + 1) + 100 ).substr(-2);
            var date:String = String( d.getDate() + 100 ).substr(-2);
            var full:String = String(d.fullYear) + month + date;
            
            var t:TextField = (addChild( new TextField() ) as TextField)
            t.appendText( full );
            
            //10月20日でテスト
            d = new Date(2011, 9, 20);
            month = String( (d.getMonth() + 1) + 100 ).substr(-2);
            date = String( d.getDate() + 100 ).substr(-2);
            full = String(d.fullYear) + month + date;
            t.appendText("\n" + full)
        }
    }
}

Forked