Skip Menu |

This queue is for tickets about the Genealogy-Gedcom-Date CPAN distribution.

Report information
The Basics
Id: 108953
Status: resolved
Priority: 0/
Queue: Genealogy-Gedcom-Date

People
Owner: Nobody in particular
Requestors: NHORNE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.01
Fixed in: 2.01



Subject: one_date equivalent
I'm trying to get the DateTime object from the new version of G:G:D. With the old version it was in the one_date element of the returned value, but I can't see where it is on the new version.
Subject: Re: [rt.cpan.org #108953] one_date equivalent
Date: Sun, 15 Nov 2015 10:04:51 +1100
To: bug-Genealogy-Gedcom-Date [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi Nigel All traces of DateTime have been removed from the new G::G::D. You'll have to construct the date either from the 'canonical' key of the returned value, if there is no calendar escape, prefix, date phrase stuff in there, or from the day/month/year keys. On 15/11/15 09:45, Nigel Horne via RT wrote: Show quoted text
> Sat Nov 14 17:45:03 2015: Request 108953 was acted upon. > Transaction: Ticket created by NHORNE > Queue: Genealogy-Gedcom-Date > Subject: one_date equivalent > Broken in: 2.01 > Severity: (no value) > Owner: Nobody > Requestors: NHORNE@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108953 > > > > I'm trying to get the DateTime object from the new version of G:G:D. With the old version it was in the one_date element of the returned value, but I can't see where it is on the new version. >
-- Ron Savage - savage.net.au
I've written this work around which I believe will work. Is this right? #!/usr/bin/env perl use strict; use warnings; use Genealogy::Gedcom::Date; use Data::Dumper; use DateTime::Format::Natural; use DateTime; my $p = Genealogy::Gedcom::Date->new(); my $r = $p->parse(date => '14 Nov 2015'); my $dfn = DateTime::Format::Natural->new(); my $q = @{$r}[0]; print $dfn->parse_datetime($q->{'canonical'})->day_name(), "\n";
Subject: Re: [rt.cpan.org #108953] one_date equivalent
Date: Sun, 15 Nov 2015 13:18:33 +1100
To: bug-Genealogy-Gedcom-Date [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi Nigel. Very nice. I've saved it for my own use. I did re-write it a bit to suits my preferences :-): #!/usr/bin/env perl use strict; use warnings; use DateTime; use DateTime::Format::Natural; use Genealogy::Gedcom::Date; # ---------------------------- my($date) = shift || '14 Nov 2015'; my($parser) = Genealogy::Gedcom::Date -> new; my($result) = $parser -> parse(date => $date); my($dfn ) = DateTime::Format::Natural -> new; my($canonical) = $$result[0]{canonical}; print "Date: $date. day_name: ", $dfn -> parse_datetime($canonical) -> day_name, ". \n"; Thanx. I'll close the ticket. Hope the new code is nice to use. On 15/11/15 12:55, Nigel Horne via RT wrote: Show quoted text
> Queue: Genealogy-Gedcom-Date > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108953 > > > I've written this work around which I believe will work. Is this right? > > #!/usr/bin/env perl > > use strict; > use warnings; > > use Genealogy::Gedcom::Date; > use Data::Dumper; > use DateTime::Format::Natural; > use DateTime; > > my $p = Genealogy::Gedcom::Date->new(); > > my $r = $p->parse(date => '14 Nov 2015'); > > my $dfn = DateTime::Format::Natural->new(); > > my $q = @{$r}[0]; > print $dfn->parse_datetime($q->{'canonical'})->day_name(), "\n"; >
-- Ron Savage - savage.net.au
Subject: Re: [rt.cpan.org #108953] one_date equivalent
Date: Sun, 15 Nov 2015 13:23:55 +1100
To: bug-Genealogy-Gedcom-Date [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi Nigel Also I just tried dates you used when reporting the old version did not handle years like 1000 and 900. The new code parses them but the DateTime result of day_name() does not match what the unix program cal shows. But, I'll leave that up to you to investigate! -- Ron Savage - savage.net.au
Thanx Nigel. Your code is correct, so closing this issue.
Subject: Re: [rt.cpan.org #108953] one_date equivalent
Date: Sat, 14 Nov 2015 19:38:40 -0500
To: bug-Genealogy-Gedcom-Date [...] rt.cpan.org
From: Nigel Horne <njh [...] bandsman.co.uk>
Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=108953 > > > Hi Nigel > > All traces of DateTime have been removed from the new G::G::D.
Oh dear, that's a shame since one of the great things about G::G::D is the ability to compare dates in Gedcom files. Show quoted text
> > You'll have to construct the date either from the 'canonical' key of the > returned value, if there is no calendar escape, prefix, date phrase > stuff in there, or from the day/month/year keys.
I'll see if I can work out how to do that, or is it documented somewhere? -Nigel
Subject: Re: [rt.cpan.org #108953] one_date equivalent
Date: Wed, 18 Nov 2015 09:40:52 +1100
To: bug-Genealogy-Gedcom-Date [...] rt.cpan.org
From: Ron Savage <ron [...] savage.net.au>
Hi Nigel On 18/11/15 07:52, njh@bandsman.co.uk via RT wrote: Show quoted text
> Queue: Genealogy-Gedcom-Date > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108953 > > >
>> <URL: https://rt.cpan.org/Ticket/Display.html?id=108953 > >> >> Hi Nigel >> >> All traces of DateTime have been removed from the new G::G::D.
> > Oh dear, that's a shame since one of the great things about G::G::D is > the ability to compare dates in Gedcom files.
>> >> You'll have to construct the date either from the 'canonical' key of the >> returned value, if there is no calendar escape, prefix, date phrase >> stuff in there, or from the day/month/year keys.
> > I'll see if I can work out how to do that, or is it documented somewhere?
It's not documented since it didn't occur to me. But it's simple. parse() returns an arrayref, with 1 element per date. 'Between x and y', and 'From x to y' both have 2 dates and hence 2 elements. All others will have 1. Each element is a hashref, so just compare the 'canonical' keys' values. This key is always present. If the reserved words, 'AFT', etc spoil the comparison, just compare the 'day', 'month' and 'year' keys. There can be a 'bce' key too, but it's missing of there was no BCE-style stuff in the input, whereas the day/month/year are /almost/ always present. It all depends in the input. And yes, all this is documented in the FAQ: https://metacpan.org/pod/Genealogy::Gedcom::Date#FAQ -- Ron Savage - savage.net.au