#!/usr/local/bin/perl -w

# Copyright 1998-1999, Paul Johnson (pjcj@transeda.com)

# This software is free.  It is licensed under the same terms as Perl itself.

# The latest version of this software should be available from my homepage:
# http://www.transeda.com/pjcj

# Version 1.01 - 27th April 1999

use strict;

require 5.004;

use diagnostics;

use Gedcom 1.01;

use vars qw( $VERSION );
$VERSION = "1.01";

eval "use Date::Manip";
Date_Init("DateFormat=UK") if $INC{"Date/Manip.pm"};

main();

sub main()
{
  my $gedcom_file = shift @ARGV;
  $| = 1;
  print "reading...";
  my $ged = Gedcom->new(grammar_file => "gedcom-5.5.grammar",
                        gedcom_file  => $gedcom_file,
                        callback     => sub { print "." });
  print "\nvalidating...\n";
  return unless $ged->validate;
# print "normalising dates...\n";
# $ged->normalise_dates("%E %b %Y");
# $ged->normalise_dates;
  print "renumbering...\n";
  $ged->renumber;
  print "ordering...\n";
  $ged->order;
  print "validating...\n";
  return unless $ged->validate;
  print "writing...\n";
  $ged->write("$gedcom_file.new");
}
