- 追加された行はこの色です。
- 削除された行はこの色です。
[[FrontPage]]
#contents
2011/08/02からのアクセス回数 &counter;
** お詫び [#ic9a2788]
QUnitの調査を進めた結果、データベースの時刻が20秒ほど前後する現象の原因が、
Ti.App.fireEventで送った時にDateの時刻がずれることが分かりました。
また、QUnit.equalsでDate型が正しく処理できないこともあり、recordのatの型
Date型からString型に変更することにしました。
ソースの修正箇所は、
record_db_test.js
#pre{{
this.setRows = function (rows) {
var res = [];
if ( rows.getRowCount() > 0 ) {
Ti.API.debug('Found: ' + rows.getRowCount() );
for (i =0; rows.isValidRow(); i++) {
var record = {};
record.id = rows.fieldByName('id');
record.weight = rows.fieldByName('weight');
var time = rows.fieldByName('at', Titanium.Database.FIELD_TYPE_DOUBLE)
var at = new Date().setTime(time);
record.at = at.toDateString();
res.push(record);
rows.next();
}
}
return res;
};
this.update = function(record) {
this.open();
var at = new Date(record.at);
var res = this.db.execute(
'UPDATE records SET weight=?, at=? WHERE id=?',
record.weight,
at.getTime(),
record.id
);
Ti.API.debug('Update DB');
this.close();
return true;
};
this.insert = function(record) {
this.open();
var at = new Date(record.at);
var res = this.db.execute(
'INSERT INTO records (weight, at) VALUES(?,?)',
record.weight,
at.getTime()
);
Ti.API.debug('Insert into DB');
this.close();
};
}}
table_view.js
#pre{{
function updateRecord (records) {
のdateLabelの設定部分
var dateLabel = Ti.UI.createLabel({
width: 290,
height: 'auto',
left: 5,
top: 5,
fontSize: 6,
textAlign: 'right'
}
);
dateLabel.text = record.at;
row.add(dateLabel);
}}
record_window.js
#pre{{
saveButton.addEventListener(
'click', function () {
var record = {};
record.id = win.record.id;
record.weight = weightField.value;
record.at = new Date(dateField.value).toDateString();
Ti.App.fireEvent(win.func, record);
win.close();
});
}}
** [#o56a7494]
** コメント [#uda5179f]
#vote(おもしろかった,そうでもない,わかりずらい)
皆様のご意見、ご希望をお待ちしております。
#comment_kcaptcha