現在時刻を取得する

getCurrentTimeを利用すると現在時刻を取得できます。 現在時刻は、例えば「20080919141132」のような「YYYYMMDDhhmmss」フォーマットの文字列です。

layout.xml


<?xml version="1.0" encoding="UTF-8"?>
<Widget>
  <Component name="widget">
    <Bitmap name="initial-bg"/>
    <Component name="normal">
      <Text name="text1" x="-100" y="0" size="32"/>
    </Component>
    <Component name="focus" visible="0">
    </Component>
    <Component name="active" visible="0">
    </Component>
  </Component>
</Widget>

widget.js


var nodeNormal = getNode("normal");
var nodeText1  = getChildNode(nodeNormal, "Text1");

function onLoad() {
  var timestr = getCurrentTime();
  setStr(nodeText1, timestr);
}

function onUpKey() {
}

function onDownKey() {
}

function onRightKey() {
}

function onLeftKey() {
}

function onConfirmKey(type) {
}

function onFocus() {
}

function onUnfocus() {
}

function onActivate() {
}


サンプルダウンロード

ウィジェットバンドル : getCurrentTime.zip


あきみち

「インターネットのカタチ - もろさが織り成す粘り強い世界 -」関連資料

インターネットのカタチ もろさが織り成す粘り強い世界

Linuxネットワークプログラミング

カスタム検索




アルファブロガー・アワード2011受賞ブログ


外部サイト

プレコ王国
ディスカス魂
金魚タイムズ
YouTubeチャネル
Twitter
Facebook
mixi(ほぼ未使用)

フィードメーター - Geekなぺーじ
Copyright (C) Geekなページ.
All rights reserved. 無断転載や無断コピーなど、私的利用の範囲を逸脱した利用はおやめ下さい.