{ "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,
\nThe 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}
\nThe return value of modificationTimestamp() can be used to\ncreate a Javascript date like this:
\nvar modificationDate = new Date(Number(timeStamp * 1000));
\nI have used this to add an HTTP If-Modified-Since header to my\nimage download HTTP requests, like this:
\nfunction leadingZero(theNumber) {
\nreturn theNumber < 10 ? '0' + theNumber : theNumber;
\n
\n}
\nfunction timeStampToIfModifiedSinceDate(timeStamp) {
\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}
\nvar file =\nTitanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,localFileName);
\nif (file.exists()) {
\nhttpClient.setRequestHeader(\"If-Modified-Since\",timeStampToIfModifiedSinceDate(Number(file.modificationTimestamp())));
\n
\n}
\nNB. On the iPhone simulator, createTimestamp() always returns 0.\nI haven't tried it on a real device.
Fixed at some point, but definitely resolved as of 1.6.0\nRC1.