Swedish calendar

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Swedish calendar

Peter Landgren

Devs,

I have added a new calendar to trunk r 11665. It is the Swedish Calendar, but I think it is valid as Finnish Calendar as well. Please report any problems i might cause!

At the same time I added the possibility to enter dates in the form yyyymmdd, which is converted to yyyy-mm-dd for analysis and usage.

Two Makefile.am and one __init__.py was also updated. Some file names were missing.

/Peter


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier
Peter, I did svn up:

U    src/plugins/import/Makefile.am
U    src/gen/lib/calendar.py
U    src/gen/lib/date.py
U    src/DateEdit.py
U    src/Filters/Rules/Person/__init__.py
U    src/Filters/Rules/Person/Makefile.am
U    src/DateHandler/_DateParser.py
U    src/DateHandler/_DateDisplay.py
U    src/DateHandler/_Date_sv.py

Now GRAMPS crashes in
src/Filters/Rules/Person/__init__.py

as NoDeathDate does not exist.

Please undo the change, as I guess you committed stuff you did not want to.
Carefully check the entire change for unwanted changes:

svn diff -r 11664 11665

Benny

2009/1/19 Peter Landgren <[hidden email]>

Devs,

I have added a new calendar to trunk r 11665. It is the Swedish Calendar, but I think it is valid as Finnish Calendar as well. Please report any problems i might cause!

At the same time I added the possibility to enter dates in the form yyyymmdd, which is converted to yyyy-mm-dd for analysis and usage.

Two Makefile.am and one __init__.py was also updated. Some file names were missing.

/Peter


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Peter Landgren

Benny,

Sorry, I forgot that I had made a "NoDeatdate"-filter.

src/Filters/Rules/Person/__init__.py and src/Filters/Rules/Person/Makefile.am are fixed now.

Maybe there is a need for such a filter. At least I needed it as I could not see any other filter method to find people without a death date.

In src/plugins/import/Makefile.am a file was missing after reorganization of src/plugins/*

The calendar caused changes in the six other files.

/Peter

> Peter, I did svn up:

>

> U src/plugins/import/Makefile.am

> U src/gen/lib/calendar.py

> U src/gen/lib/date.py

> U src/DateEdit.py

> U src/Filters/Rules/Person/__init__.py

> U src/Filters/Rules/Person/Makefile.am

> U src/DateHandler/_DateParser.py

> U src/DateHandler/_DateDisplay.py

> U src/DateHandler/_Date_sv.py

>

> Now GRAMPS crashes in

> src/Filters/Rules/Person/__init__.py

>

> as NoDeathDate does not exist.

>

> Please undo the change, as I guess you committed stuff you did not want to.

> Carefully check the entire change for unwanted changes:

>

> svn diff -r 11664 11665

>

> Benny

>

> 2009/1/19 Peter Landgren <[hidden email]>

>

> > Devs,

> >

> > I have added a new calendar to trunk r 11665. It is the Swedish Calendar,

> > but I think it is valid as Finnish Calendar as well. Please report any

> > problems i might cause!

> >

> > At the same time I added the possibility to enter dates in the form

> > yyyymmdd, which is converted to yyyy-mm-dd for analysis and usage.

> >

> > Two Makefile.am and one __init__.py was also updated. Some file names

> > were missing.

> >

> > /Peter

> >

> >

> >

> > -------------------------------------------------------------------------

> >----- This SF.net email is sponsored by:

> > SourcForge Community

> > SourceForge wants to tell your story.

> > http://p.sf.net/sfu/sf-spreadtheword

> > _______________________________________________

> > Gramps-devel mailing list

> > [hidden email]

> > https://lists.sourceforge.net/lists/listinfo/gramps-devel

--

Peter Landgren

Talken Hagen

671 94 BRUNSKOG

0570-530 21

070-635 4719

[hidden email]

Skype: pgl4820.2


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

jerome
Peter,


1. On src/DateHandler/_DateParser.py :

def swedish_valid(date_tuple):
     valid = gregorian_valid(date_tuple)
     # not sure how <= and >= works with tuples???
     date_tuple = (date_tuple[2], date_tuple[1], date_tuple[0])
     if date_tuple <= (1700,2,28):
         valid = False
     if date_tuple == (1700,2,29):  # leapday 1700 was skipped
         valid = False
     if date_tuple == (1712,2,30):  # extra day was inserted 1712
         valid = True
     if date_tuple >= (1712,3,1):   # back to julian
         valid = False
     return valid

def _parse_swedish(self, text):
         return self._parse_calendar(text, self._stext, self._stext2,
                                     self.swedish_to_int,swedish_valid)


   if subparser == self._parse_swedish:
      check = swedish_valid


I should be able to understand added code but dates will be invalid on
parsing. Date could be marked as invalid but no calendar reference.
Maybe there is less problem because swedish calendar uses the same
number of months and same year as gregorian calendar : there is a minor
calendar conversion !

gregorian_ymd -> swedish_sdn -> gregorian_ymd


2. It will be great if we could remove the "wart" on _Date_fr.py and
provide code for all users, which fix a calendar_conversion error
(Gregorian->French->Gegorian)
Maybe adding something on gen/lib/Calendar.py :

def french_sdn(year, month, day):
     """Convert a French Republican Calendar date to an SDN number."""
     return (year*_FR_DAYS_PER_4_YEARS)/4 + \
            (month-1)*_FR_DAYS_PER_MONTH + \
            day + _FR_SDN_OFFSET

year <= 0 returns wrong value :
# before 1792.9.22 (ymd), start of french_calendar

1789-7-14 (Gregorian) => -3 Messidor 26 (-3.10.26 on French_calendar)

_FR_DAYS_PER_4_YEARS   = 1461

(-3* 1461)/4 =-1095.75

def gregorian_ymd(sdn):
temp = (_GRG_SDN_OFFSET + sdn) * 4 - 1

     # Calculate the century (year/100)
     century = temp / _GRG_DAYS_PER_400_YEARS

     # Calculate the year and day of year (1 <= day_of_year <= 366)
     temp = ((temp % _GRG_DAYS_PER_400_YEARS) / 4) * 4 + 3
     year = (century * 100) + (temp / _GRG_DAYS_PER_4_YEARS)

_GRG_SDN_OFFSET         = 32045
_GRG_DAYS_PER_400_YEARS = 146097
_GRG_DAYS_PER_4_YEARS   = 1461

temp = (32045 -1095.75) *4 -1 = 123796
century = 123796 / 146097 = 0,84735484

temp = ((123796 % 146097) / 4) *4 + 3 = ???
year = (0,84735484 * 100) + (temp / 1461) = ???

Does someone have an idea for fixing calendar_conversion mistakes ?
Doug ?


3. Also, why sometimes 'b' is used as alternate letter for month 'm' ?

src/DateHandler/_DateParser.py
         fmt = GrampsLocale.tformat
         match = self._fmt_parse.match(fmt.lower())
         if match:
             self.dmy = (match.groups() == ('d', 'm', 'y') or \
                        match.groups() == ('d', 'b', 'y'))
             self.ymd = (match.groups() == ('y', 'm', 'd') or \
                        match.groups() == ('y', 'b', 'd'))
         else:
             self.dmy = True
             self.ymd = False

I suppose it is for altenate calendars or it is related to GrampsLocale,
isn't it ?



Jérôme R.




Peter Landgren a écrit :

>
>
> Benny,
>
> Sorry, I forgot that I had made a "NoDeatdate"-filter.
>
> src/Filters/Rules/Person/__init__.py and
> src/Filters/Rules/Person/Makefile.am are fixed now.
>
> Maybe there is a need for such a filter. At least I needed it as I could
> not see any other filter method to find people without a death date.
>
> In src/plugins/import/Makefile.am a file was missing after
> reorganization of src/plugins/*
>
> The calendar caused changes in the six other files.
>
> /Peter
>
>  > Peter, I did svn up:
>
>  >
>
>  > U src/plugins/import/Makefile.am
>
>  > U src/gen/lib/calendar.py
>
>  > U src/gen/lib/date.py
>
>  > U src/DateEdit.py
>
>  > U src/Filters/Rules/Person/__init__.py
>
>  > U src/Filters/Rules/Person/Makefile.am
>
>  > U src/DateHandler/_DateParser.py
>
>  > U src/DateHandler/_DateDisplay.py
>
>  > U src/DateHandler/_Date_sv.py
>
>  >
>
>  > Now GRAMPS crashes in
>
>  > src/Filters/Rules/Person/__init__.py
>
>  >
>
>  > as NoDeathDate does not exist.
>
>  >
>
>  > Please undo the change, as I guess you committed stuff you did not
> want to.
>
>  > Carefully check the entire change for unwanted changes:
>
>  >
>
>  > svn diff -r 11664 11665
>
>  >
>
>  > Benny
>
>  >
>
>  > 2009/1/19 Peter Landgren <[hidden email]>
>
>  >
>
>  > > Devs,
>
>  > >
>
>  > > I have added a new calendar to trunk r 11665. It is the Swedish
> Calendar,
>
>  > > but I think it is valid as Finnish Calendar as well. Please report any
>
>  > > problems i might cause!
>
>  > >
>
>  > > At the same time I added the possibility to enter dates in the form
>
>  > > yyyymmdd, which is converted to yyyy-mm-dd for analysis and usage.
>
>  > >
>
>  > > Two Makefile.am and one __init__.py was also updated. Some file names
>
>  > > were missing.
>
>  > >
>
>  > > /Peter
>
>  > >
>
>  > >
>
>  > >
>
>  > >
> -------------------------------------------------------------------------
>
>  > >----- This SF.net email is sponsored by:
>
>  > > SourcForge Community
>
>  > > SourceForge wants to tell your story.
>
>  > > http://p.sf.net/sfu/sf-spreadtheword
>
>  > > _______________________________________________
>
>  > > Gramps-devel mailing list
>
>  > > [hidden email]
>
>  > > https://lists.sourceforge.net/lists/listinfo/gramps-devel
>
> --
>
> Peter Landgren
>
> Talken Hagen
>
> 671 94 BRUNSKOG
>
> 0570-530 21
>
> 070-635 4719
>
> [hidden email]
>
> Skype: pgl4820.2
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gramps-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gramps-devel



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Peter Landgren

Jérôme,

> Peter,

>

>

> 1. On src/DateHandler/_DateParser.py :

>

> def swedish_valid(date_tuple):

> valid = gregorian_valid(date_tuple)

> # not sure how <= and >= works with tuples???

> date_tuple = (date_tuple[2], date_tuple[1], date_tuple[0])

> if date_tuple <= (1700,2,28):

> valid = False

> if date_tuple == (1700,2,29): # leapday 1700 was skipped

> valid = False

> if date_tuple == (1712,2,30): # extra day was inserted 1712

> valid = True

> if date_tuple >= (1712,3,1): # back to julian

> valid = False

> return valid

>

> def _parse_swedish(self, text):

> return self._parse_calendar(text, self._stext, self._stext2,

> self.swedish_to_int,swedish_valid)

>

>

> if subparser == self._parse_swedish:

> check = swedish_valid

>

>

> I should be able to understand added code but dates will be invalid on

> parsing. Date could be marked as invalid but no calendar reference.

> Maybe there is less problem because swedish calendar uses the same

> number of months and same year as gregorian calendar : there is a minor

> calendar conversion !

>

> gregorian_ymd -> swedish_sdn -> gregorian_ymd

Note:

The Swedish calendar is only valid between 1700-03-01 and 1712-02-30.

Dates outside this span will be flagged as not valid. I did this, as for that period, either Julian nor Gregorian is correct. Before 1700-03-01 it was Julian and between 1712-03-01 and 1753-02-17 it was also Julian and after that it was Gregorian.

Hope this will explain some of the code. I will update the Wiki with information about the Swedish calendar.

/Peter


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier


2009/1/20 Peter Landgren <[hidden email]>

Jérôme,

> Peter,

>

>

> 1. On src/DateHandler/_DateParser.py :

>

> def swedish_valid(date_tuple):

> valid = gregorian_valid(date_tuple)

> # not sure how <= and >= works with tuples???

> date_tuple = (date_tuple[2], date_tuple[1], date_tuple[0])

> if date_tuple <= (1700,2,28):

> valid = False

> if date_tuple == (1700,2,29): # leapday 1700 was skipped

> valid = False

> if date_tuple == (1712,2,30): # extra day was inserted 1712

> valid = True

> if date_tuple >= (1712,3,1): # back to julian

> valid = False

> return valid

>

> def _parse_swedish(self, text):

> return self._parse_calendar(text, self._stext, self._stext2,

> self.swedish_to_int,swedish_valid)

>

>

> if subparser == self._parse_swedish:

> check = swedish_valid

>

>

> I should be able to understand added code but dates will be invalid on

> parsing. Date could be marked as invalid but no calendar reference.

> Maybe there is less problem because swedish calendar uses the same

> number of months and same year as gregorian calendar : there is a minor

> calendar conversion !

>

> gregorian_ymd -> swedish_sdn -> gregorian_ymd

Note:

The Swedish calendar is only valid between 1700-03-01 and 1712-02-30.

Dates outside this span will be flagged as not valid. I did this, as for that period, either Julian nor Gregorian is correct. Before 1700-03-01 it was Julian and between 1712-03-01 and 1753-02-17 it was also Julian and after that it was Gregorian.

Hope this will explain some of the code. I will update the Wiki with information about the Swedish calendar.


I have no problem with invalid date under the following condition:

1/user has a valid date: 1/1/2000
2/he mistakenly/deliberately converts in date editor to swedish/french. What happens?
3/he returns to the correct  date ==> date should again show 1/1/2000

Benny

/Peter



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier
In reply to this post by jerome


2009/1/20 Jérôme <[hidden email]>
Peter,



Does someone have an idea for fixing calendar_conversion mistakes ?
Doug ?

If there is an error, it should be fixed everywhere. We can produce a point update with an announcement that some dates where wrongly converted in the past.

 
3. Also, why sometimes 'b' is used as alternate letter for month 'm' ?

b and B are codes in locale that corresponds to writing months with the full names instead of with numbers

Benny
 


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Peter Landgren
In reply to this post by Benny Malengier

> > Note:

> >

> > The Swedish calendar is only valid between 1700-03-01 and 1712-02-30.

> >

> > Dates outside this span will be flagged as not valid. I did this, as for

> > that period, either Julian nor Gregorian is correct. Before 1700-03-01 it

> > was Julian and between 1712-03-01 and 1753-02-17 it was also Julian and

> > after that it was Gregorian.

> >

> > Hope this will explain some of the code. I will update the Wiki with

> > information about the Swedish calendar.

>

> I have no problem with invalid date under the following condition:

>

> 1/user has a valid date: 1/1/2000

> 2/he mistakenly/deliberately converts in date editor to swedish/french.

> What happens?

> 3/he returns to the correct date ==> date should again show 1/1/2000

When I try this I get an invalid date and if I then go to the DateEdit dialog I get this error:

Unhandled exception

Traceback (most recent call last):

File "/home/peter/svn/GRAMPSTRUNK/trunk/src/DateEdit.py", line 159, in invoke_date_editor

date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track)

File "/home/peter/svn/GRAMPSTRUNK/trunk/src/DateEdit.py", line 253, in __init__

self.dual_dated.set_sensitive(0)

AttributeError: DateEditorDialog instance has no attribute 'dual_dated'

I get the same error when I try to use the DateEdit dialog with a not valid date with any calender.

/Peter


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Douglas S. Blank
Peter Landgren wrote:

[snip]

> When I try this I get an invalid date and if I then go to the DateEdit
> dialog I get this error:
>
> Unhandled exception
>
> Traceback (most recent call last):
>
> File "/home/peter/svn/GRAMPSTRUNK/trunk/src/DateEdit.py", line 159, in
> invoke_date_editor
>
> date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track)
>
> File "/home/peter/svn/GRAMPSTRUNK/trunk/src/DateEdit.py", line 253, in
> __init__
>
> self.dual_dated.set_sensitive(0)
>
> AttributeError: DateEditorDialog instance has no attribute 'dual_dated'
>
> I get the same error when I try to use the DateEdit dialog with a not
> valid date with any calender.

That's odd. I would think that that could only happen if I didn't commit
the changes to the glade file, or you haven't updated yours. I'll check
this evening on my end.

-Doug

> /Peter

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

jerome
In reply to this post by Benny Malengier
Benny,

> We can produce a point update with an announcement that some dates where wrongly
> converted in the past.

Maybe I should re-open the bug-report (generated on 2006-09-13, fixed on
2008-02-09) : http://www.gramps-project.org/bugs/view.php?id=445 ...

> If there is an error, it should be fixed everywhere.

*Why only modifications on _Date_fr.py ?*
I had added something on _Date_fr (tested before 3.0.x) because
convertion error generates date error and people using french calendar
are mostly french speaking people. If you are looking at 'Issue
History', I made a change (working with iso format and french_calendar
displayer) to avoid mistakes and was validated by using tests on
localized date_handler but was not very confortable to make change on
RelLib (gen/lib). I knew it was not the best place. Now, I think this
could be fixed on gen/lib/Calendar.py by using something like:

def french_sdn(year, month, day):
     """Convert a French Republican Calendar date to an SDN number."""
     y = (year*_FR_DAYS_PER_4_YEARS)/4
     m = (month-1)*_FR_DAYS_PER_MONTH
     d = day + _FR_SDN_OFFSET
     sdn = y + m + d
     # do not convert dates before 22.9.1792 or after 1.1.1806
     if sdn < 2375840 or sdn > 2380688 :
         return gregorian_sdn(year, month, day)
     else:
         return sdn

def french_ymd(sdn):
     """Convert an SDN number to a French Republican Calendar date."""
     # only between 22.9.1792 and 1.1.1806
     print sdn
     if sdn >= 2375840 and sdn <= 2380688:
         temp = (sdn-_FR_SDN_OFFSET)*4 - 1
         year = temp/_FR_DAYS_PER_4_YEARS
         day_of_year = (temp%_FR_DAYS_PER_4_YEARS)/4
         month = (day_of_year/_FR_DAYS_PER_MONTH)+1
         day = (day_of_year%_FR_DAYS_PER_MONTH)+1
         return (year, month, day)
     else:
         return gregorian_ymd(sdn)

I am not able to add a test on src/gen/lib/test/date_test.py
but this should happen with main date_handler and related code (other
locale)

> b and B are codes in locale that corresponds to writing months with the
> full names instead of with numbers

thank you !


Jérôme


Benny Malengier a écrit :

>
>
> 2009/1/20 Jérôme <[hidden email] <mailto:[hidden email]>>
>
>     Peter,
>
>
>
>     Does someone have an idea for fixing calendar_conversion mistakes ?
>     Doug ?
>
>
> If there is an error, it should be fixed everywhere. We can produce a
> point update with an announcement that some dates where wrongly
> converted in the past.
>
>  
>
>     3. Also, why sometimes 'b' is used as alternate letter for month 'm' ?
>
>
> b and B are codes in locale that corresponds to writing months with the
> full names instead of with numbers
>
> Benny
>  
>



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier


2009/1/20 Jérôme <[hidden email]>
Benny,


We can produce a point update with an announcement that some dates where wrongly converted in the past.

Maybe I should re-open the bug-report (generated on 2006-09-13, fixed on 2008-02-09) : http://www.gramps-project.org/bugs/view.php?id=445 ...


If there is an error, it should be fixed everywhere.

*Why only modifications on _Date_fr.py ?*
I had added something on _Date_fr (tested before 3.0.x) because convertion error generates date error and people using french calendar are mostly french speaking people. If you are looking at 'Issue History', I made a change (working with iso format and french_calendar displayer) to avoid mistakes and was validated by using tests on localized date_handler but was not very confortable to make change on RelLib (gen/lib). I knew it was not the best place. Now, I think this could be fixed on gen/lib/Calendar.py by using something like:


def french_sdn(year, month, day):
   """Convert a French Republican Calendar date to an SDN number."""
   y = (year*_FR_DAYS_PER_4_YEARS)/4
   m = (month-1)*_FR_DAYS_PER_MONTH
   d = day + _FR_SDN_OFFSET
   sdn = y + m + d
   # do not convert dates before 22.9.1792 or after 1.1.1806
   if sdn < 2375840 or sdn > 2380688 :
       return gregorian_sdn(year, month, day)
   else:
       return sdn

def french_ymd(sdn):
   """Convert an SDN number to a French Republican Calendar date."""
   # only between 22.9.1792 and 1.1.1806
   print sdn
   if sdn >= 2375840 and sdn <= 2380688:
       temp = (sdn-_FR_SDN_OFFSET)*4 - 1
       year = temp/_FR_DAYS_PER_4_YEARS
       day_of_year = (temp%_FR_DAYS_PER_4_YEARS)/4
       month = (day_of_year/_FR_DAYS_PER_MONTH)+1
       day = (day_of_year%_FR_DAYS_PER_MONTH)+1
       return (year, month, day)
   else:
       return gregorian_ymd(sdn)


This looks ok, and should be easily tested by somebody who knows french republican dates like you.
 


I am not able to add a test on src/gen/lib/test/date_test.py
but this should happen with main date_handler and related code (other locale)

If the correct conversion is in the normal date handler, then adding a test should be possible, yes? Please do so.

Benny


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Peter Landgren
In reply to this post by Benny Malengier

[snip]

> > Note:

> >

> > The Swedish calendar is only valid between 1700-03-01 and 1712-02-30.

> >

> > Dates outside this span will be flagged as not valid. I did this, as for

> > that period, either Julian nor Gregorian is correct. Before 1700-03-01 it

> > was Julian and between 1712-03-01 and 1753-02-17 it was also Julian and

> > after that it was Gregorian.

> >

> > Hope this will explain some of the code. I will update the Wiki with

> > information about the Swedish calendar.

>

> I have no problem with invalid date under the following condition:

>

> 1/user has a valid date: 1/1/2000

> 2/he mistakenly/deliberately converts in date editor to swedish/french.

> What happens?

> 3/he returns to the correct date ==> date should again show 1/1/2000

>

There is a conflict here.

1. If the date is not valid the calender is not stored with the date.

So then I can't return the correct date when I switch back calendar

according to 1/, 2/, 3/ above.

2. If set the date valid (even if it's not) the calendar is stored

with the date and I can convert back correctly if I switch calendar.

Is there a problem with storing the calendar with the date if the date is not valid?

/Peter


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier


2009/1/21 Peter Landgren <[hidden email]>

[snip]

> > Note:

> >

> > The Swedish calendar is only valid between 1700-03-01 and 1712-02-30.

> >

> > Dates outside this span will be flagged as not valid. I did this, as for

> > that period, either Julian nor Gregorian is correct. Before 1700-03-01 it

> > was Julian and between 1712-03-01 and 1753-02-17 it was also Julian and

> > after that it was Gregorian.

> >

> > Hope this will explain some of the code. I will update the Wiki with

> > information about the Swedish calendar.

>

> I have no problem with invalid date under the following condition:

>

> 1/user has a valid date: 1/1/2000

> 2/he mistakenly/deliberately converts in date editor to swedish/french.

> What happens?

> 3/he returns to the correct date ==> date should again show 1/1/2000

>

There is a conflict here.

1. If the date is not valid the calender is not stored with the date.

So then I can't return the correct date when I switch back calendar

according to 1/, 2/, 3/ above.

2. If set the date valid (even if it's not) the calendar is stored

with the date and I can convert back correctly if I switch calendar.

Is there a problem with storing the calendar with the date if the date is not valid?


Can you not do like the code Jerome showed.
If a person enters a swedish date, it is:
1/or within the boundaries those dates are jused, and hence valid or wrong
2/or out of the boundaries the date is used

For 2, don't set it invalid, but instead define the swedish calendar to be the gregorian calendar outside the valid dates. So eg 2001-1-1 (Swedish) is the Gregorian date.

This means: From Swedish to other calendar there is no problem, because it was valid or not valid in the swedish. Only problem is that valid Gregorian has to switch to valid Swedish. This should be possible as every day is per definition valid, and hence you should know what that date was in swedish. It would be the real swedish calendar, and become gregorian otherwise.

To have ranges in the calendar (as in only use calendar in this range), we would need another thing instead of making it an invalid date. We should give an indicator instead in the date editor I believe. Should be possible, we only need to define the snd for every calendar that makes it correct, and do it

Perhaps you have to point me the code that gives the


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

jerome
In reply to this post by Benny Malengier
> If there is an error, it should be fixed everywhere. We can produce a
> point update with an announcement that some dates where wrongly
> converted in the past.

There is conditions for generating error :

1. using negative value as year (B.C.E) on french_calendar
(date out of calendar = not on certificates or archives)
2. multiple conversion
user need to use a negative year on french_calendar (see above) and to
make a second conversion to an other calendar
(steps working with Serial Date Number and ISO date format)
3. user accepts changes

With a custom french_calendar displayer, this just added a warning by
making date invalid (red box) but most users cancelled change when they
get this B.C.E iso date. I suppose it is what Peter did on
_DateParser.py with def swedish_valid(date_tuple)and he made tests for
writting def swedish_sdn(year, month, day), def swedish_ymd(sdn) on
Calendar.py.
For conversion ?
Benny points out better what is the problem (relation invalid/conversion).

Maybe a new test (src/gen/lib/test/date_test.py), like :

+ a date with iso format date (year, month, day)
+ a calendar
+ to get the sdn by using def calendar_sdn(year, month, day) : the template.

+ test with others calendars
+ to use the sdn on def calendar_ymd(sdn), we get a iso format date
(year, month, day)
+ to get the sdn by using testing calendar def calendar_sdn(year, month,
day)
+ to compare template sdn with sdn produced by testing calendar

will enlighten possible conversion mistakes !
I know that the french calendar was stopped and there was conception
(design) error.
Nevertheless, whatever calendar used we should have the same sdn.

Also, there is def convert_calendar(self, calendar) and/or def
to_calendar(self, calendar_name) functions present on /src/gen/lib/date.py



Jérôme


Benny Malengier a écrit :

>
>
> 2009/1/20 Jérôme <[hidden email] <mailto:[hidden email]>>
>
>     Peter,
>
>
>
>     Does someone have an idea for fixing calendar_conversion mistakes ?
>     Doug ?
>
>
> If there is an error, it should be fixed everywhere. We can produce a
> point update with an announcement that some dates where wrongly
> converted in the past.
>
>  
>
>     3. Also, why sometimes 'b' is used as alternate letter for month 'm' ?
>
>
> b and B are codes in locale that corresponds to writing months with the
> full names instead of with numbers
>
> Benny
>  
>



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

jerome
In reply to this post by Peter Landgren
What about Swedish calendar import/export ?

* to xml
* to GEDCOM
Maybe to set 'unknown' ! Only available with <DATE_CALENDAR_ESCAPE>:

@#DGREGORIAN@
@#DJULIAN@
@#DHEBREW@
@#DFRENCH R@
@#DROMAN@
@#DUNKNOWN@

http://homepages.rootsweb.ancestry.com/~pmcbride/gedcom/55gcch2.htm#DATE_CALENDAR_ESCAPE

Seems GRAMPS does not support ROMAN calendar yet ... :-D
(Note: there is no def on GEDCOM spec, was for future definition !!!)
http://en.wikipedia.org/wiki/Roman_calendar


Peter Landgren a écrit :

>
>
> [snip]
>
>  > > Note:
>
>  > >
>
>  > > The Swedish calendar is only valid between 1700-03-01 and 1712-02-30.
>
>  > >
>
>  > > Dates outside this span will be flagged as not valid. I did this,
> as for
>
>  > > that period, either Julian nor Gregorian is correct. Before
> 1700-03-01 it
>
>  > > was Julian and between 1712-03-01 and 1753-02-17 it was also Julian and
>
>  > > after that it was Gregorian.
>
>  > >
>
>  > > Hope this will explain some of the code. I will update the Wiki with
>
>  > > information about the Swedish calendar.
>
>  >
>
>  > I have no problem with invalid date under the following condition:
>
>  >
>
>  > 1/user has a valid date: 1/1/2000
>
>  > 2/he mistakenly/deliberately converts in date editor to swedish/french.
>
>  > What happens?
>
>  > 3/he returns to the correct date ==> date should again show 1/1/2000
>
>  >
>
> There is a conflict here.
>
> 1. If the date is not valid the calender is not stored with the date.
>
> So then I can't return the correct date when I switch back calendar
>
> according to 1/, 2/, 3/ above.
>
> 2. If set the date valid (even if it's not) the calendar is stored
>
> with the date and I can convert back correctly if I switch calendar.
>
> Is there a problem with storing the calendar with the date if the date
> is not valid?
>
> /Peter
>



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Peter Landgren

Jerome,

> What about Swedish calendar import/export ?

>

> * to xml

This works.

> * to GEDCOM

You are right. This does not work. No calender is written, assuming Gregorian then.

So, maybe this is the thing that halts this project, not being fully GEDCOM transportable?

/Peter

> Maybe to set 'unknown' ! Only available with <DATE_CALENDAR_ESCAPE>:

>

> @#DGREGORIAN@

> @#DJULIAN@

> @#DHEBREW@

> @#DFRENCH R@

> @#DROMAN@

> @#DUNKNOWN@

>

> http://homepages.rootsweb.ancestry.com/~pmcbride/gedcom/55gcch2.htm#DATE_CA

>LENDAR_ESCAPE

>

> Seems GRAMPS does not support ROMAN calendar yet ... :-D

> (Note: there is no def on GEDCOM spec, was for future definition !!!)

> http://en.wikipedia.org/wiki/Roman_calendar

>

> Peter Landgren a écrit :

> > [snip]

> >

> > > > Note:

> > > >

> > > >

> > > >

> > > > The Swedish calendar is only valid between 1700-03-01 and

> > > > 1712-02-30.

> > > >

> > > >

> > > >

> > > > Dates outside this span will be flagged as not valid. I did this,

> >

> > as for

> >

> > > > that period, either Julian nor Gregorian is correct. Before

> >

> > 1700-03-01 it

> >

> > > > was Julian and between 1712-03-01 and 1753-02-17 it was also Julian

> > > > and

> > > >

> > > > after that it was Gregorian.

> > > >

> > > >

> > > >

> > > > Hope this will explain some of the code. I will update the Wiki with

> > > >

> > > > information about the Swedish calendar.

> > >

> > > I have no problem with invalid date under the following condition:

> > >

> > >

> > >

> > > 1/user has a valid date: 1/1/2000

> > >

> > > 2/he mistakenly/deliberately converts in date editor to

> > > swedish/french.

> > >

> > > What happens?

> > >

> > > 3/he returns to the correct date ==> date should again show 1/1/2000

> >

> > There is a conflict here.

> >

> > 1. If the date is not valid the calender is not stored with the date.

> >

> > So then I can't return the correct date when I switch back calendar

> >

> > according to 1/, 2/, 3/ above.

> >

> > 2. If set the date valid (even if it's not) the calendar is stored

> >

> > with the date and I can convert back correctly if I switch calendar.

> >

> > Is there a problem with storing the calendar with the date if the date

> > is not valid?

> >

> > /Peter

--

Peter Landgren

Talken Hagen

671 94 BRUNSKOG

0570-530 21

070-635 4719

[hidden email]

Skype: pgl4820.2


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier


2009/1/21 Peter Landgren <[hidden email]>

Jerome,

> What about Swedish calendar import/export ?

>

> * to xml

This works.

> * to GEDCOM

You are right. This does not work. No calender is written, assuming Gregorian then.

So, maybe this is the thing that halts this project, not being fully GEDCOM transportable?


Not necessarily. If the date written out is in iso format with (swedish) behind  it (with calendar @#DUNKNOWN@), GRAMPS should parse it correctly as we can parse such a date as swedish calendar date. Other genea apps without swedish will not recognize this date, but if they do like gramps, they should just show the information as given in the GEDCOM (like gramps does with the text attribute of the date).

Benny

/Peter

> Maybe to set 'unknown' ! Only available with <DATE_CALENDAR_ESCAPE>:

>

> @#DGREGORIAN@

> @#DJULIAN@

> @#DHEBREW@

> @#DFRENCH R@

> @#DROMAN@

> @#DUNKNOWN@

>

> http://homepages.rootsweb.ancestry.com/~pmcbride/gedcom/55gcch2.htm#DATE_CA

>LENDAR_ESCAPE

>

> Seems GRAMPS does not support ROMAN calendar yet ... :-D

> (Note: there is no def on GEDCOM spec, was for future definition !!!)

> http://en.wikipedia.org/wiki/Roman_calendar

>

> Peter Landgren a écrit :

> > [snip]

> >

> > > > Note:

> > > >

> > > >

> > > >

> > > > The Swedish calendar is only valid between 1700-03-01 and

> > > > 1712-02-30.

> > > >

> > > >

> > > >

> > > > Dates outside this span will be flagged as not valid. I did this,

> >

> > as for

> >

> > > > that period, either Julian nor Gregorian is correct. Before

> >

> > 1700-03-01 it

> >

> > > > was Julian and between 1712-03-01 and 1753-02-17 it was also Julian

> > > > and

> > > >

> > > > after that it was Gregorian.

> > > >

> > > >

> > > >

> > > > Hope this will explain some of the code. I will update the Wiki with

> > > >

> > > > information about the Swedish calendar.

> > >

> > > I have no problem with invalid date under the following condition:

> > >

> > >

> > >

> > > 1/user has a valid date: 1/1/2000

> > >

> > > 2/he mistakenly/deliberately converts in date editor to

> > > swedish/french.

> > >

> > > What happens?

> > >

> > > 3/he returns to the correct date ==> date should again show 1/1/2000

> >

> > There is a conflict here.

> >

> > 1. If the date is not valid the calender is not stored with the date.

> >

> > So then I can't return the correct date when I switch back calendar

> >

> > according to 1/, 2/, 3/ above.

> >

> > 2. If set the date valid (even if it's not) the calendar is stored

> >

> > with the date and I can convert back correctly if I switch calendar.

> >

> > Is there a problem with storing the calendar with the date if the date

> > is not valid?

> >

> > /Peter

--

Peter Landgren

Talken Hagen

671 94 BRUNSKOG

0570-530 21

070-635 4719

[hidden email]

Skype: pgl4820.2



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Peter Landgren

> 2009/1/21 Peter Landgren <[hidden email]>

>

> > Jerome,

> >

> > > What about Swedish calendar import/export ?

> > >

> > >

> > >

> > > * to xml

> >

> > This works.

> >

> > > * to GEDCOM

> >

> > You are right. This does not work. No calender is written, assuming

> > Gregorian then.

> >

> > So, maybe this is the thing that halts this project, not being fully

> > GEDCOM transportable?

>

> Not necessarily. If the date written out is in iso format with (swedish)

> behind it (with calendar @#DUNKNOWN@), GRAMPS should parse it correctly as

> we can parse such a date as swedish calendar date. Other genea apps without

> swedish will not recognize this date, but if they do like gramps, they

> should just show the information as given in the GEDCOM (like gramps does

> with the text attribute of the date).

GEDCOM import of

DATE 1700-05-01 (swedish)

works already, sets correct calendar.

but

DATE @#DUNKNOWN@ 1700-05-01 (swedish)

results in 1700-05-01.

So I need to fix:

1. GEDCOM import to take care of @#DUNKNOWN@

2. GEDCOM export put @#DUNKNOWN@ before the ISO-date and append (swedish).

or maby only

2. GEDCOM export append (swedish) after ISO-date.

To do a test with the "Text only" option in the EditDate gui and I entered:

1700-05-01 (swedish)

and I get this error:

Traceback (most recent call last):

File "/home/peter/GRAMPSTRUNK/share/gramps/DateEdit.py", line 159, in invoke_date_editor

date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track)

File "/home/peter/GRAMPSTRUNK/share/gramps/DateEdit.py", line 288, in __init__

the_value, the_text, the_newyear) = self.build_date_from_ui()

ValueError: need more than 5 values to unpack

If I enter just a valid date, no error.

My plan was to see how GRAMPS GEDCOM exported something like "1700-05-01 (swedish)"

/Peter


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Benny Malengier


2009/1/21 Peter Landgren <[hidden email]>

> 2009/1/21 Peter Landgren <[hidden email]>

>

> > Jerome,

> >

> > > What about Swedish calendar import/export ?

> > >

> > >

> > >

> > > * to xml

> >

> > This works.

> >

> > > * to GEDCOM

> >

> > You are right. This does not work. No calender is written, assuming

> > Gregorian then.

> >

> > So, maybe this is the thing that halts this project, not being fully

> > GEDCOM transportable?

>

> Not necessarily. If the date written out is in iso format with (swedish)

> behind it (with calendar @#DUNKNOWN@), GRAMPS should parse it correctly as

> we can parse such a date as swedish calendar date. Other genea apps without

> swedish will not recognize this date, but if they do like gramps, they

> should just show the information as given in the GEDCOM (like gramps does

> with the text attribute of the date).

GEDCOM import of

DATE 1700-05-01 (swedish)

works already, sets correct calendar.

but

DATE @#DUNKNOWN@ 1700-05-01 (swedish)

results in 1700-05-01.

So I need to fix:

1. GEDCOM import to take care of @#DUNKNOWN@

2. GEDCOM export put @#DUNKNOWN@ before the ISO-date and append (swedish).

or maby only

2. GEDCOM export append (swedish) after ISO-date.

To do a test with the "Text only" option in the EditDate gui and I entered:

1700-05-01 (swedish)

and I get this error:

Traceback (most recent call last):

File "/home/peter/GRAMPSTRUNK/share/gramps/DateEdit.py", line 159, in invoke_date_editor

date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track)

File "/home/peter/GRAMPSTRUNK/share/gramps/DateEdit.py", line 288, in __init__

the_value, the_text, the_newyear) = self.build_date_from_ui()

ValueError: need more than 5 values to unpack


This should be an old error in trunk, it should be fixed if you create a new family tree an import an xml file into it.
If not, there is some code Douglas forgot when upgrading the date object, send then the bug to him.

About the GEDCOM, is the @#DUNKNOWN@ an issue? A find and replace by nothing fixes it. That is, is it related to you adding swedish calendar that it crashes?

Benny


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Swedish calendar

Douglas S. Blank
> 2009/1/21 Peter Landgren <[hidden email]>
>> Traceback (most recent call last):
>>
>> File "/home/peter/GRAMPSTRUNK/share/gramps/DateEdit.py", line 159, in
>> invoke_date_editor
>>
>> date_dialog = DateEditorDialog(self.date_obj, self.uistate, self.track)
>>
>> File "/home/peter/GRAMPSTRUNK/share/gramps/DateEdit.py", line 288, in
>> __init__
>>
>> the_value, the_text, the_newyear) = self.build_date_from_ui()
>>
>> ValueError: need more than 5 values to unpack
>>

That was a bug related to the newyear offset codes. Fixed. Thanks!

-Doug

> This should be an old error in trunk, it should be fixed if you create a
> new
> family tree an import an xml file into it.
> If not, there is some code Douglas forgot when upgrading the date object,
> send then the bug to him.
>
> About the GEDCOM, is the @#DUNKNOWN@ an issue? A find and replace by
> nothing
> fixes it. That is, is it related to you adding swedish calendar that it
> crashes?
>
> Benny
>


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
12