Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.079 X-Spam-Evidence: '*H*': 0.84; '*S*': 0.00; 'subject:not': 0.03; 'string.': 0.05; 'json': 0.07; 'parser': 0.07; 'suddenly': 0.07; 'seemed': 0.09; 'subject:Why': 0.09; 'api,': 0.16; 'ios': 0.16; 'recorded': 0.16; 'two.': 0.16; 'app': 0.19; 'server,': 0.19; 'format,': 0.24; 'parse': 0.24; 'rest': 0.29; 'leave': 0.29; 'received:172.16': 0.29; 'returned': 0.30; 'getting': 0.31; '8bit%:2': 0.31; 'pan': 0.31; 'subject:the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'dates': 0.36; 'thanks': 0.36; 'subject:?': 0.36; 'being': 0.38; 'message- id:@gmail.com': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'skip:t 30': 0.61; 'today.': 0.61; 'simply': 0.61; 'times': 0.62; 'header:Message-Id:1': 0.63; 'hearing': 0.63; 'skip:n 10': 0.64; 'decided': 0.64; 'love': 0.65; 'charset:windows-1252': 0.65; 'series': 0.66; 'side': 0.67; 'between': 0.67; 'doesn\x92t': 0.84; 'haven\x92t': 0.84; 'milliseconds': 0.84; 'points,': 0.84; 'resulted': 0.84; 'transmitting': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:message-id:date :to:mime-version; bh=61SzR0hoayz/pFYZcfDUvkKXDEAreA9h9UbZ1gwnnZ4=; b=egtPPtCKEw5mA+pKTH5LyEEhyJeCInqF1TKx92DWuLMCtkmbCz+wXX/xyuh1PiVT4f epdv+R9wNnsHhm9eomhL6SV0W/n5jYSxI3Ld/V/m2v3U344LQZ+1onUdyyauPwkxUTl6 k038yHcMY2/d364BW5niBcsOFEM/ANfD8HxxjBkYhlyKpZPayxlvx675Bp72Yk4omiYT D2dP7ucX3wSAgm+wq6aJwX6oT2kJDlCU/4H9Gw9KQx8nGvFG8FAolhWK7j+R5gQ2vk6q JTQf6t7y6L1z9Gd/TbspE01gAIhb1f8sTIeqcnnSzKDoBVrK58dMSrImiMXBOR/A66q+ 7NDA== X-Received: by 10.68.134.198 with SMTP id pm6mr48949522pbb.9.1398211546972; Tue, 22 Apr 2014 17:05:46 -0700 (PDT) From: Travis Griggs Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Why does isoformat() optionally not print the fractional seconds? Date: Tue, 22 Apr 2014 17:05:44 -0700 To: python-list@python.org Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) X-Mailer: Apple Mail (2.1874) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398211550 news.xs4all.nl 2972 [2001:888:2000:d::a6]:41954 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70521 Python(3) let me down today. Better to be explicit, and all that, didn=92t= pan out for me. I have time series data being recorded in a mongo database (I love = pymongo). I have an iOS app that consumes the data. Since JSON doesn=92t = have a time format, I have to stringify the times when transmitting = between the two. To parse it on the obj-c side, I use=20 NSDateFormatter *parser =3D [NSDateFormatter new]; parser =3D [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; [parser setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.S=94]; NSDate *date =3D [parser dateFromString: thatJsonString]; Which was working swimmingly, until I started getting occasional and = infrequent nil dates at times. I thought I had a storage issue or = something with my REST api, or the server, or something. But it was = simply now and then again, why 1000=92s of data points, I managed to get = 0 milliseconds from time to time, which resulted in the isoformat() I = was using to suddenly leave off the .S part of the string. And since the = parse then failed, the iOS side decided it wasn=92t valid and returned a = nil. Haven=92t decided where/how I=92ll work around it yet, but the = isoformat() seemed unpythonic to me today. Thanks for hearing me whine.