This is a migrated thread and some comments may be shown as answers.

SQLitePlugin - Initial Experience

2 Answers 64 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 1
Michael asked on 19 Mar 2013, 03:14 PM
Would it make sense to have a separate 'Plugin' area in the forums? I wasn't sure where to post this.

I have started using the SQLite plugin and thought i would share my experience with storing dates.

Before i begin does anyone know if there is a way to stop all the SQLitePlugin console messages appearing? there is a lot of them and it is hard to see all my own messages with the SQLitePlugin messages being displayed as well.

Dates:
Initially I tried storing dates in the database as  an integer (ms from 1st Jan 1970) using getTime()
and then converting the interger back to a js Date Object using new Date(databaseValue)

This worked OK in Android 2.3 but for some reason in Android 4.03 the values were not being stored correctly,  e.g. the number 1361836800000 became 332167168 when read back from the database. I've no idea why!

I then moved to storing the dates as TEXT in the format yyyy-MM-dd HH:mm:ss using kendo.toString(date, "yyyy-MM-dd HH:mm:ss") to convert the date to  a string for saving in the db and new Date(strdate) to convert from database string back to a date.
This works in Android 2.3 & 4.03 but failed in IOS 5 AHHHHHH!!!
It turns out that some IOS browsers don't accept one of the most common datetime formats!! I finally ended up writing a date function that splits out the date elements from the string before converting then to a javascript Date object, so far so good, i hope this helps others.

  if(!strdate)
        return new Date(0);
    else
    {
        arr = strdate.split(/[- :]/);
        return new Date(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]);
    }

Kendo UI / Icenium Team, how about some more detailed demos using the SQLitePlugin please, the one I found was very basic, it would be good to see proper date manipulation and using it with kendo DataSource & MVVM scenarios.

2 Answers, 1 is accepted

Sort by
0
Jan-Dirk
Top achievements
Rank 1
answered on 19 Mar 2013, 04:03 PM
With regard to console messages, could it be that Icenium has set the 'log level' to 'debug':
https://github.com/brodyspark/PhoneGap-SQLitePlugin-Android#android-platform

The issues you are seeing are also maybe related to the plug-in itself and not to Icenium (it is a plugin after all).
0
Michael
Top achievements
Rank 1
answered on 19 Mar 2013, 09:56 PM
The log level set to DEBUG could be the problem but how can I remove / change it from within Icenium?

I would like to make it clear my problems with dates & SQLite are general problems with javascript dates & SQLlite development and not with Icenium, its just such a fundamental problem I thought I would share so it may help others.
Tags
General Discussion
Asked by
Michael
Top achievements
Rank 1
Answers by
Jan-Dirk
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Share this question
or