Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81188

Re: Using Python for date calculations

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 <python-python-list@m.gmane.org>
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 <breamoreboy@yahoo.co.uk>
Subject Re: Using Python for date calculations
Date Fri, 21 Nov 2014 10:20:06 +0000
References <k7tt6aheccqv06enkume0vs0v6kvvhns45@4ax.com> <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16091.1416565221.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-21 10:35 +0200
  Re: Using Python for date calculations Chris Angelico <rosuav@gmail.com> - 2014-11-21 19:40 +1100
    Re: Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-21 12:15 +0200
      Re: Using Python for date calculations Chris Angelico <rosuav@gmail.com> - 2014-11-21 21:18 +1100
      Re: Using Python for date calculations alister <alister.nospam.ware@ntlworld.com> - 2014-11-21 10:33 +0000
        Re: Using Python for date calculations Chris Angelico <rosuav@gmail.com> - 2014-11-21 21:47 +1100
        Re: Using Python for date calculations random832@fastmail.us - 2014-11-21 08:54 -0500
          Re: Using Python for date calculations alister <alister.nospam.ware@ntlworld.com> - 2014-11-21 14:54 +0000
        Re: Using Python for date calculations random832@fastmail.us - 2014-11-21 08:58 -0500
          Re: Using Python for date calculations Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-22 01:55 +1100
            Re: Using Python for date calculations Ned Batchelder <ned@nedbatchelder.com> - 2014-11-21 10:25 -0500
        Re: Using Python for date calculations Chris Angelico <rosuav@gmail.com> - 2014-11-22 01:08 +1100
      Re: Using Python for date calculations Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-11-21 14:50 -0500
        Re: Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-22 07:07 +0200
          Re: Using Python for date calculations Chris Angelico <rosuav@gmail.com> - 2014-11-22 16:13 +1100
  Re: Using Python for date calculations Gary Herron <gary.herron@islandtraining.com> - 2014-11-21 00:50 -0800
  Re: Using Python for date calculations Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-21 10:20 +0000
    Re: Using Python for date calculations alister <alister.nospam.ware@ntlworld.com> - 2014-11-21 10:38 +0000
    Re: Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-21 17:50 +0200
      Re: Using Python for date calculations Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-21 16:01 +0000
  Re: Using Python for date calculations Chris Angelico <rosuav@gmail.com> - 2014-11-21 21:27 +1100
  Re: Using Python for date calculations duncan smith <buzzard@invalid.invalid> - 2014-11-21 17:03 +0000
    Re: Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-21 21:48 +0200
      Re: Using Python for date calculations Dennis Lee Bieber <bieber.genealogy@earthlink.net> - 2014-11-21 15:32 -0500
  Re: Using Python for date calculations Dennis Lee Bieber <bieber.genealogy@earthlink.net> - 2014-11-21 14:35 -0500
    Re: Using Python for date calculations Paul Blair <p.blair@internode.on.net> - 2014-11-22 06:51 +1100
      Re: Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-22 07:31 +0200
    Re: Using Python for date calculations Denis Beauregard <denis.b-at-francogene.com@fr.invalid> - 2014-11-21 15:07 -0500
      Re: Using Python for date calculations Steve Hayes <hayesstw@telkomsa.net> - 2014-11-22 07:34 +0200

csiph-web