Timestamp conversion issues

I’m helping my brother update one of his company’s older iPhone apps. It’s currently an Objective-C app but he wants it redone from the ground up in Corona so it’s more portable.

Anyway, I’ve never done something like this before so I’m running into an issue with timestamps. We have to grandfather in the sqlite database so old users don’t lose their data on the update. No issues there except the timestamps look like:

379356709.83319
379356709.83457

I’ve been googling for the past hour but have no idea what kind of timestamps those are, I’ve never developed an Objective-C app so that’s making the search a lot more difficult. A bit of guidance on what they are and where to look for converting them to a seconds-format that os.date() can accept would be much appreciated. [import]uid: 194435 topic_id: 34710 reply_id: 334710[/import]

What data type is the field in the database that the dates are stored in? [import]uid: 8271 topic_id: 34710 reply_id: 137907[/import]

Column type is TIMESTAMP [import]uid: 194435 topic_id: 34710 reply_id: 137908[/import]

Try this: http://stackoverflow.com/questions/6284341/inserting-timestamps-into-sqlite [import]uid: 8271 topic_id: 34710 reply_id: 137912[/import]

The first part should be a linux timestamp, the portion after the decimal point is I believe a sub-millisecond precision thanks to Objective-C/C’s time library. If all you need as accuracy to the second everything before the decimal is fine.

See: http://www.epochconverter.com/
with your value of: 379356709
you get: GMT: Fri, 08 Jan 1982 16:51:49 GMT

I would verify with the rendered date in iOS to verify this, but your formatting functions should reveal the format that its stored in. [import]uid: 130806 topic_id: 34710 reply_id: 138013[/import]

Definitely not a unix timestamp, both the time stamps in my first post represent January 8th, 2013 (verified via simulator on xcode). I did some digging through the Obj-C code base and it looks to be saving an “NSDate” variable in that field, which leads me to believe it’s got nothing to do with sqlite, but I could be misled. [import]uid: 194435 topic_id: 34710 reply_id: 138014[/import]

I think I got it, appears to be a timestamp representing seconds (and milliseconds on the fraction) since 01/01/2000 00:00:00

Unix timestamp for the above is 946706400

946706400 + 379356709.83457 = 1326063109.83457
= 01 / 08 / 12 @ 4:51:49pm EST [import]uid: 194435 topic_id: 34710 reply_id: 138028[/import]

What data type is the field in the database that the dates are stored in? [import]uid: 8271 topic_id: 34710 reply_id: 137907[/import]

Column type is TIMESTAMP [import]uid: 194435 topic_id: 34710 reply_id: 137908[/import]

Try this: http://stackoverflow.com/questions/6284341/inserting-timestamps-into-sqlite [import]uid: 8271 topic_id: 34710 reply_id: 137912[/import]

The first part should be a linux timestamp, the portion after the decimal point is I believe a sub-millisecond precision thanks to Objective-C/C’s time library. If all you need as accuracy to the second everything before the decimal is fine.

See: http://www.epochconverter.com/
with your value of: 379356709
you get: GMT: Fri, 08 Jan 1982 16:51:49 GMT

I would verify with the rendered date in iOS to verify this, but your formatting functions should reveal the format that its stored in. [import]uid: 130806 topic_id: 34710 reply_id: 138013[/import]

Definitely not a unix timestamp, both the time stamps in my first post represent January 8th, 2013 (verified via simulator on xcode). I did some digging through the Obj-C code base and it looks to be saving an “NSDate” variable in that field, which leads me to believe it’s got nothing to do with sqlite, but I could be misled. [import]uid: 194435 topic_id: 34710 reply_id: 138014[/import]

I think I got it, appears to be a timestamp representing seconds (and milliseconds on the fraction) since 01/01/2000 00:00:00

Unix timestamp for the above is 946706400

946706400 + 379356709.83457 = 1326063109.83457
= 01 / 08 / 12 @ 4:51:49pm EST [import]uid: 194435 topic_id: 34710 reply_id: 138028[/import]