Oddly I have not found a date that would NOT give your example.txt
EDIT: Ahh because you created it in the future!! (November 14th)
And a different timezone!
I don't know how I could create it in the future (it would be nice)
on my computer:
Code:
kMDItemFSCreationDate = 2010-10-14 10:22:05 +0200
Yes, I now see this with 'touch' on 10.6.3. The query seems to be automatically excluding files that are zero-length from its results. Append one byte to the file and it will appear in the results for me. YMMV.
Zero-length files are NOT excluded on older OS versions. I happened to be using 10.4.11 when I reported results of my earlier test. YMMV.
It seems not to be that simple...zero-length files created from a program (for example TextEdit) or files born with a length different from 0 and then emptied (i.e. launch echo "test" > file.txt, then open file.txt with an editor and empty it) are correctly found by spotlight.
Besides, I'm not 100% sure, but I think I have a couple of empty files created with touch and correctly found by spotlight...
When was the last time you restarted? Maybe something is wrong with the mdimporter daemon.
Last time...about five minutes ago. However, I turn it off every day when I go to bed.
If I were you, I'd submit the test program to Apple's bugreporter. Be sure to include suitable data that reliably causes the problem, or a procedure for creating files that reliably show the problem. The uploaded example.txt doesn't show the problem, because its metadata wasn't included, AFAICT.
You may have trouble archiving a file with the metadata to show the problem, so I suggest concentrating on a series of commands, perhaps using echo or touch, that can create a local file with the proper metadata.
http://developer.apple.com/bugreporter
The problem is that I cannot tell to Apple much more than what I can tell to you...Actually what I did is not so much different from what you did to test the code:
- create a file calling touch file1.txt
- try to find it with Test (0 results)
- try to find it with Spotlight (0 results)
- launch echo "example" > file1.txt
- try to find it with Spotlight (found)
- call mdls file1.txt and get the exact creation date
- insert the exact creation date less a second as date in Test and search (0 results)
- insert the exact creation date less an hour and a second in Test and search (found)
same thing if, instead of using NSDatePicker to get the date (even if I don't think there are problems about it), I insert it manually in the code, calling dateWithNaturalLanguageString or even dateWithString (the correct format is the one showed by mdls).
Furthermore, I followed these identical instructions on a friend's mac (10.6.4 if I don't get wrong) with the same results.
Probable daylight savings time error.
Sorry, I missed your post, but actually is exactly what I'm thinking of...In fact normally I should be GMT+1, not +2 as it's in this period of the year.
But examining the metadata of the file I read
Code:
kMDItemFSCreationDate = 2010-10-14 10:22:05 +0200
so it should understand that the file has been created during daylight saving time and results should be coherent with that. Besides, setting the date (manually or through NSDatePicker) the date is 2010-10.... +0200, so it should work correctly...