{ "id": "61395", "key": "TIMOB-763", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:54:10.000+0000", "created": "2011-04-15T02:35:51.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "createtimestamp", "filesystem", "ios", "modificationtimestamp" ], "versions": [], "issuelinks": [], "assignee": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:54:10.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

Hi,

\n

The TiFilesystemFileProxy.createTimestamp() and\nTiFilesystemFileProxy.modificationTimestamp() methods return a\nboolean value rather than the real value. A fix for this is\nbelow.

\n

-(id)createTimestamp:(id)args {

\n
\nNSError * error = nil;\nNSDictionary * resultDict = [fm attributesOfItemAtPath:path error:&error];\nif (error!=nil) return NUMBOOL(NO);\nNSDate * date = [resultDict objectForKey:NSFileCreationDate];\nreturn NUMLONG([date timeIntervalSince1970]);\n
\n

}

\n

-(id)modificationTimestamp:(id)args {

\n
\nNSError * error = nil;\nNSDictionary * resultDict = [fm attributesOfItemAtPath:path error:&error];\nif (error!=nil) return NUMBOOL(NO);\nNSDate * date = [resultDict objectForKey:NSFileModificationDate];\nreturn NUMLONG([date timeIntervalSince1970]);\n
\n

}

\n

The return value of modificationTimestamp() can be used to\ncreate a Javascript date like this:

\n

var modificationDate = new Date(Number(timeStamp * 1000));

\n

I have used this to add an HTTP If-Modified-Since header to my\nimage download HTTP requests, like this:

\n

function leadingZero(theNumber) {

\n
\nreturn theNumber < 10 ? '0' + theNumber : theNumber;\n
\n

}

\n

function timeStampToIfModifiedSinceDate(timeStamp) {

\n
\nvar modificationDate = new Date(Number(timeStamp * 1000));\n\nreturn dayNames[modificationDate.getUTCDay()] + \", \" +\n        leadingZero(modificationDate.getUTCDate()) + \" \" +\n        monthNames[modificationDate.getUTCMonth()] + \" \" +\n        modificationDate.getUTCFullYear() + \" \" +\n        leadingZero(modificationDate.getUTCHours()) + \":\" +\n        leadingZero(modificationDate.getUTCMinutes()) + \":\" +\n        leadingZero(modificationDate.getUTCSeconds()) + \" UTC \";\n
\n

}

\n

var file =\nTitanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,localFileName);

\n

if (file.exists()) {

\n
\nhttpClient.setRequestHeader(\"If-Modified-Since\",timeStampToIfModifiedSinceDate(Number(file.modificationTimestamp())));\n
\n

}

\n

NB. On the iPhone simulator, createTimestamp() always returns 0.\nI haven't tried it on a real device.

{html}", "attachment": [], "flagged": false, "summary": "TiFilesystemFileProxy.modificationTimestamp() does not return the real value", "creator": { "name": "fooman", "key": "fooman", "displayName": "FooMan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "fooman", "key": "fooman", "displayName": "FooMan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "123967", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Fixed at some point, but definitely resolved as of 1.6.0\nRC1.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:35:52.000+0000", "updated": "2011-04-15T02:35:52.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }