Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'python.': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'subject:Python': 0.06; 'steve': 0.09; 'lawrence': 0.09; 'links.': 0.09; "person's": 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'things,': 0.09; 'wrong,': 0.09; 'python': 0.11; 'language.': 0.14; 'calculator': 0.16; 'hayes': 0.16; 'illustrates': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'when,': 0.16; 'language': 0.16; 'wrote:': 0.18; 'module': 0.19; 'python?': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; "i've": 0.25; 'script': 0.25; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'heading': 0.30; 'usually': 0.31; 'era': 0.31; 'gary': 0.31; 'anyone': 0.31; "we're": 0.32; 'worked': 0.33; 'url:python': 0.33; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'convert': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'dates': 0.36; 'done': 0.36; 'url:org': 0.36; 'too': 0.37; 'easily': 0.37; 'sometimes': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'that,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'simple,': 0.60; 'matter': 0.61; 'course': 0.61; 'simple': 0.61; "you've": 0.63; 'kind': 0.63; 'our': 0.64; 'pick': 0.64; 'more': 0.64; 'finally': 0.65; 'charset:windows-1252': 0.65; 'worth': 0.66; 'research,': 0.68; 'records,': 0.69; 'programs,': 0.74; 'age': 0.80; 'hand': 0.80; 'age.': 0.84; 'census': 0.84; 'kiss': 0.84; 'mention.': 0.84; 'much,': 0.84; 'received:btcentralplus.com': 0.84; 'subject:Using': 0.84; 'understand,': 0.84; 'birth': 0.91; 'received:86': 0.91; 'average': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Using Python for date calculations Date: Fri, 21 Nov 2014 10:20:06 +0000 References: <546EFCC5.6000705@islandtraining.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host86-151-25-168.range86-151.btcentralplus.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <546EFCC5.6000705@islandtraining.com> 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: 65 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416565221 news.xs4all.nl 2936 [2001:888:2000:d::a6]:37335 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81188 On 21/11/2014 08:50, Gary Herron wrote: > On 11/21/2014 12:35 AM, Steve Hayes wrote: >> I've finally found a use for Python. >> >> When, in the course of my genealogy research, I look at census or burial >> records, I often want to work out a person's date of birth from their >> age. >> It's a simple matter of mental arithmetic, but I sometimes get it >> wrong, and >> mislead myself. There are calculators and date calculation programs, >> but they >> are usually too complicated and try to do too much, so by the time you've >> worked out what to do it takes much longer. >> >> This Python script does it for me. >> >> year = input("Year: ") >> age = input("Age: ") >> born = year-age >> print 'Year of birth:', born >> >> It's so simple, so elementary, that it's not really worth writing about, >> except for the fact that it illustrates the KISS principle. >> >> It is sometimes better to have a simple program that does one thing >> well than >> a complex one that does lots of things, but none of them very >> efficiently. >> >> The average hand calculator can do the same job, but you have to pick >> it up >> and put it down, and you can't easily see if you've made a typo. >> >> Having said that, however, yes, I would perhaps like to use Python for >> more >> complicated date processing routines, namely to convert the kinds of >> dates >> produced by genealogy programs to a simple yyyy-mm-dd that computer >> database >> programs can understand, so that "Abt May 1677" would be rendered as >> "1677-05-00" >> >> Has anyone done something like that in Python? >> >> >> > > The datetime module has lots of capabilities including the several you > mention. > > See https://docs.python.org/2/library/datetime.html > > Gary Herron > As we're now firmly heading into the Python 3 era would people please be kind enough to use the Python 3 links. I know it's only a single character change but it's the principle to me. TIA. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence