Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'test,': 0.07; 'subject:How': 0.10; 'stored': 0.12; '0.2': 0.16; '33,': 0.16; 'igor': 0.16; 'math,': 0.16; 'reliably': 0.16; 'seconds,': 0.16; 'timestamp': 0.16; 'accordingly.': 0.16; '>>>': 0.22; 'handling': 0.26; 'shown': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; '>>>>': 0.31; 'skip:d 20': 0.34; 'subject:the': 0.34; 'subject:from': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'subject:?': 0.36; 'hi,': 0.36; 'thank': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'you.': 0.62; 'subject:get': 0.81; 'believe,': 0.84; 'calculations': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=cWyCSNF3/mlaMnJfpUNRWfieMPr8HmbvR5xvvdFuxXY=; b=PKXGcA5KVaL+nGUPL0dZjNvCpSR2DqH7R2kFANAXUWhONmfLO++R2sMU1Pxt2JZbth lbKlANmp4Zb8gS3/vLHUu719VMaBlPDgRpLB9U8S1a2G13GI7SI/pq/13h2Q1PaoWP9M wo4EeNptFQMY9SeJP1+uJkLc1BQcM7TQbNQ0K3T7QGiP+4xhgvAHfwPg52Eb8/ldSwk+ L2hx2w4LLxXvnFJCj//pmb02OAVdP0+7nu1qZtGPVVjsn/Ouc5+cceOCIh0+lGMNU7+G 5TOlm07G/J8t+CyT6XOgUgJcyPqBgvNZr0urZYmqlwVJ0nkC731pIY4/QjemiFkotzy8 nW5g== MIME-Version: 1.0 X-Received: by 10.140.47.18 with SMTP id l18mr50397449qga.9.1398158117932; Tue, 22 Apr 2014 02:15:17 -0700 (PDT) In-Reply-To: References: Date: Tue, 22 Apr 2014 11:15:17 +0200 Subject: Re: How to properly get the microseconds from the timestamps? From: Vlastimil Brom To: python Content-Type: text/plain; charset=UTF-8 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398158127 news.xs4all.nl 2880 [2001:888:2000:d::a6]:34657 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70493 2014-04-22 4:38 GMT+02:00 Igor Korot : ... >>>> datetime.datetime.fromtimestamp(1092787200/1000.0) > datetime.datetime(1970, 1, 13, 7, 33, 7, 200000) > > Is there a way to know if the timestamp has a microseconds? > > Thank you. > -- Hi, I believe, in these cases, you can just test, whether there is a non-integer part in the timestamp in seconds, which will be stored as microseconds accordingly. >>> 1092787200/1000.0 1092787.2 0.2 s is stored (and shown in repr(...)) as 200000 microseconds. There are some peculiarities in handling date and time calculations reliably as well as in the floating point math, but they don't seem to be involved here.