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


Groups > comp.lang.python > #81193

Re: Using Python for date calculations

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.roellig-ltd.de!open-news-network.org!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!post01.fr7!fx19.am4.POSTED!not-for-mail
From alister <alister.nospam.ware@ntlworld.com>
Subject Re: Using Python for date calculations
Newsgroups comp.lang.python
References <k7tt6aheccqv06enkume0vs0v6kvvhns45@4ax.com> <546EFCC5.6000705@islandtraining.com> <mailman.16091.1416565221.18130.python-list@python.org>
User-Agent Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Lines 65
Message-ID <YCEbw.852078$KL.247217@fx19.am4> (permalink)
NNTP-Posting-Host 82.9.78.47
X-Complaints-To http://netreport.virginmedia.com
X-Trace 1416566328 82.9.78.47 (Fri, 21 Nov 2014 10:38:48 UTC)
NNTP-Posting-Date Fri, 21 Nov 2014 10:38:48 UTC
Organization virginmedia.com
Date Fri, 21 Nov 2014 10:38:48 GMT
X-Received-Body-CRC 3029089999
X-Received-Bytes 3359
Xref csiph.com comp.lang.python:81193

Show key headers only | View raw


On Fri, 21 Nov 2014 10:20:06 +0000, Mark Lawrence wrote:

> 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.

I think this was because the OP is clearly using python 2
he may be better of moving to python 3 but providing links to documents 
of his current version is probably more helpful than providing python 3 
links-in this case



-- 
Martin was probably ripping them off.  That's some family, isn't it?
Incest, prostitution, fanaticism, software.
		-- Charles Willeford, "Miami Blues"

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