Difference between revisions of "Calendar tools holidays"

From Gramps
Jump to: navigation, search
m (Gramps)
(19 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:Plugins]][[Category:Translators/Categories]][[Category:Developers/General]]
+
Explanation of how to add or change the holidays appearing on the output of the calendars in Gramps. This includes the Text:''Birthday and Anniversary Report'', the Graphical:''Calendar'' Report, and the ''Web Calendar''.
  
This article explains how to add or change the holidays appearing on the output of the calendar tool.
+
==Calendar Holidays==
  
==Calendar Holidays==
+
Gramps comes with three Calendar-based reports:
Gramps now comes with three Calendar-based reports: a Calendar, and a Birthday and Anniversary report, and an output for the Web. If you would like to add your country's holidays to the calendar, then you can add them to the file gramps/plugins/holidays.xml. Here, you can add recurring annual events in a variety of ways. The format is generally:
+
# Calendar (menu {{man menu|Reports->Graphical Reports->Calendar...}} )
<nowiki>
+
# Birthday and Anniversary Report (menu {{man menu|Reports->Text Reports->Birthday and Anniversary Report...}} )
  <?xml version="1.0" encoding="iso-8859-1"?>
+
# And an output for the Web (menu {{man menu|Reports->Web Pages->Web Calendar...}} )
 +
 
 +
If you would like to add your country's holidays to the calendar, then you can add them to the file [http://gramps.svn.sourceforge.net/viewvc/gramps/trunk/src/plugins/lib/holidays.xml.in?view=markup holidays.xml.in]. Here, you can add recurring annual events in a variety of ways. The format is generally:
 +
 
 +
<code>
 +
  <?xml version="1.0" encoding="UTF-8"?>
 
  <calendar>
 
  <calendar>
   <country name=COUNTRYNAME>
+
   <country _name=COUNTRYNAME>
 
     <date name=NAME value=VALUE type=TYPE offset=OFFSET if=EXPRESSION />
 
     <date name=NAME value=VALUE type=TYPE offset=OFFSET if=EXPRESSION />
 
     ...
 
     ...
 
   </country>
 
   </country>
   <country name=COUNTRYNAME>
+
   <country _name=COUNTRYNAME>
 
     <date name=NAME value=VALUE type=TYPE offset=OFFSET if=EXPRESSION />
 
     <date name=NAME value=VALUE type=TYPE offset=OFFSET if=EXPRESSION />
 
     ...
 
     ...
Line 18: Line 23:
 
   ...
 
   ...
 
  </calendar>
 
  </calendar>
</nowiki>
+
</code>
 
   
 
   
 
where each of the capitalized words would be filled in with appropriate values, as follows. All but NAME and VALUE are optional.
 
where each of the capitalized words would be filled in with appropriate values, as follows. All but NAME and VALUE are optional.
Line 25: Line 30:
 
*NAME => the text to appear on the calendar
 
*NAME => the text to appear on the calendar
 
*TYPE => "secular", "religious", "personal", "informational" (This isn't currently used in the calendar, but could be. Use these keywords, untranslated.)
 
*TYPE => "secular", "religious", "personal", "informational" (This isn't currently used in the calendar, but could be. Use these keywords, untranslated.)
*EXPRESSION => a python expression that must be true for this to appear on the calendar. You can use y, m, and d variables (for year, month, and day, all integers). See VALUE for examples. '''DEPRICATED. This is no longer permitted.'''
+
*EXPRESSION => a python expression that must be true for this to appear on the calendar. You can use y, m, and d variables (for year, month, and day, all integers). See VALUE for examples.  
*VALUE => "YEAR/MONTH/DAY" or "YEAR/NUMBER/DAYCODE/MONCODE" or "> EXPRESSION" (which evaluates to one of the previous two types of VALUES). Current useful expression values are:
+
*VALUE =>  
** "> easter(y)" (Easter for current year)
+
** "YEAR/MONTH/DAY"
** "> dst(y)[0]" (Daylight Saving Time, "us", start)
+
*** "2012/12/25"
** "> dst(y)[1]" (Daylight Saving Time, "us", end)
+
*** "*/12/25"
** "> dst(y, "eu")[0]" (Daylight Saving Time, "eu", start)
+
** "YEAR/MONCODE/DAY"
** "> dst(y, "eu")[1]" (Daylight Saving Time, "eu", end)
+
*** "2012/dec/25"
 +
*** "*/dec/25"
 +
** "YEAR/NUMBER/DAYCODE/MONCODE" (nth day of week in month, year)
 +
*** "2012/1/mon/dec" (first monday in december, 2012)
 +
*** "*/-1/tue/dec" (last tuesday in december, every year)
 +
** "> EXPRESSION" (which evaluates to one of the previous two types of VALUES). Current useful expression values are:
 +
*** "> easter(y)" (Easter for current year)
 +
*** "> dst(y)[0]" (Daylight Saving Time, "us", start)
 +
*** "> dst(y)[1]" (Daylight Saving Time, "us", end)
 +
*** "> dst(y, "eu")[0]" (Daylight Saving Time, "eu", start)
 +
*** "> dst(y, "eu")[1]" (Daylight Saving Time, "eu", end)
 +
*** "> dow(y, m, d) == 1" (dow returns the iso weekday number, where Monday is 1 and Sunday is 7)
 
*YEAR => "*" or an actual year. "*" means any year.
 
*YEAR => "*" or an actual year. "*" means any year.
 
*MONTH => "*" or actual month number. "*" means any month.
 
*MONTH => "*" or actual month number. "*" means any month.
Line 37: Line 53:
 
*NUMBER => number of weekday in month. For example, "every 3rd Tuesday in April" would be "*/3/tue/apr". NUMBER can also be negative, which means it is counted from the end of the month. "last Tuesday in April 2007" could be "2007/-1/tue/4"
 
*NUMBER => number of weekday in month. For example, "every 3rd Tuesday in April" would be "*/3/tue/apr". NUMBER can also be negative, which means it is counted from the end of the month. "last Tuesday in April 2007" could be "2007/-1/tue/4"
 
*DAYCODE => "mon", "tue", "wed", "thu", "fri", "sat", or "sun". Do not translate these words; use all lowercase.
 
*DAYCODE => "mon", "tue", "wed", "thu", "fri", "sat", or "sun". Do not translate these words; use all lowercase.
*MONCODE => MONTH, or 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', or 'dec'. String version should not be translated; use all lowercase.
+
*MONCODE =>  
*OFFSET => DAYCODE or a number (either may be negative) that offsets the day determined above. If it is a DAYCODE, then it will find the next DAYCODE that is either the same as this day, or the next(+)/prev(-) one.
+
** MONTH
 +
** 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', or 'dec'. (not be translated; use all lowercase)
 +
*OFFSET =>  
 +
** number (may be negative) that offsets the day determined by VALUE
 +
** DAYCODE (may be negative), the next DAYCODE that is either the same as this day, or the next(+)/prev(-) one.
 +
** "workday" or "weekend" (may be negative) - the next workday/weekend that is on this day, or the next/prev
 +
 
 +
== Translations ==
 +
 
 +
Holiday entries are generally written for a specific country, and thus typcailly don't need to be written for more than one language. However, it might be appropriate to have your entries country name and holiday text be translated into the language that Gramps is running in. To make a country name or holiday name get translated, simply precede the name of the XML item with an underscore. For example:
 +
 
 +
<pre>
 +
  ...
 +
  <country _name="Jewish Holidays">
 +
    <date _name="Purim" value="> passover(y)" offset="-30"/>
 +
    <date _name="Passover" value="> passover(y)" offset="0"/>
 +
    ...
 +
  </country>
 +
  ...
 +
</pre>
 +
 
 +
In this example, "Jewish Holidays", "Purim", and "Passover" will be looked up in the Gramps gettext system for translations. If you would like to help add those translations, please see [[Translating Gramps]].
  
 
==Examples==
 
==Examples==
  
<nowiki>
+
<code>
  <?xml version="1.0" encoding="iso-8859-1"?>
+
  <?xml version="1.0" encoding="UTF-8"?>
 
  <calendar>
 
  <calendar>
 
   <country name="United States">
 
   <country name="United States">
Line 70: Line 107:
 
   </country>
 
   </country>
 
  </calendar>
 
  </calendar>
</nowiki>
+
</code>
  
 
The last set will only load if your country is Finland. It says that Card Night is the last Thursday of every month, every year. Let's play!  
 
The last set will only load if your country is Finland. It says that Card Night is the last Thursday of every month, every year. Let's play!  
  
Note that you can have two separate holidays.xml files: one where gramps is installed, and one in your personal .gramps/plugins/ folder.
+
Note that you can have two separate holidays.xml files: one where Gramps is installed, and one in your personal .gramps/plugins/ folder.
 +
 
 +
[[Category:Plugins]]
 +
[[Category:Translators/Categories]]
 +
[[Category:Developers/General]]
 +
[[Category:Reports]]

Revision as of 01:15, 20 January 2013

Explanation of how to add or change the holidays appearing on the output of the calendars in Gramps. This includes the Text:Birthday and Anniversary Report, the Graphical:Calendar Report, and the Web Calendar.

Calendar Holidays

Gramps comes with three Calendar-based reports:

  1. Calendar (menu Reports->Graphical Reports->Calendar... )
  2. Birthday and Anniversary Report (menu Reports->Text Reports->Birthday and Anniversary Report... )
  3. And an output for the Web (menu Reports->Web Pages->Web Calendar... )

If you would like to add your country's holidays to the calendar, then you can add them to the file holidays.xml.in. Here, you can add recurring annual events in a variety of ways. The format is generally:

<?xml version="1.0" encoding="UTF-8"?>
<calendar>
  <country _name=COUNTRYNAME>
    <date name=NAME value=VALUE type=TYPE offset=OFFSET if=EXPRESSION />
    ...
  </country>
  <country _name=COUNTRYNAME>
    <date name=NAME value=VALUE type=TYPE offset=OFFSET if=EXPRESSION />
    ...
  </country>
  ...
</calendar>

where each of the capitalized words would be filled in with appropriate values, as follows. All but NAME and VALUE are optional.

  • COUNTRYNAME => "United States", "China", etc. You don't have to make these countries, however. You can make these just a "holiday set" which could be "Christian", "Muslim", "Eastern European", etc. These names can be selected from a list when running calendar-related reports. You can use your own language for this name.
  • NAME => the text to appear on the calendar
  • TYPE => "secular", "religious", "personal", "informational" (This isn't currently used in the calendar, but could be. Use these keywords, untranslated.)
  • EXPRESSION => a python expression that must be true for this to appear on the calendar. You can use y, m, and d variables (for year, month, and day, all integers). See VALUE for examples.
  • VALUE =>
    • "YEAR/MONTH/DAY"
      • "2012/12/25"
      • "*/12/25"
    • "YEAR/MONCODE/DAY"
      • "2012/dec/25"
      • "*/dec/25"
    • "YEAR/NUMBER/DAYCODE/MONCODE" (nth day of week in month, year)
      • "2012/1/mon/dec" (first monday in december, 2012)
      • "*/-1/tue/dec" (last tuesday in december, every year)
    • "> EXPRESSION" (which evaluates to one of the previous two types of VALUES). Current useful expression values are:
      • "> easter(y)" (Easter for current year)
      • "> dst(y)[0]" (Daylight Saving Time, "us", start)
      • "> dst(y)[1]" (Daylight Saving Time, "us", end)
      • "> dst(y, "eu")[0]" (Daylight Saving Time, "eu", start)
      • "> dst(y, "eu")[1]" (Daylight Saving Time, "eu", end)
      • "> dow(y, m, d) == 1" (dow returns the iso weekday number, where Monday is 1 and Sunday is 7)
  • YEAR => "*" or an actual year. "*" means any year.
  • MONTH => "*" or actual month number. "*" means any month.
  • DAY => "*" or actual day number in month. "*" means any day.
  • NUMBER => number of weekday in month. For example, "every 3rd Tuesday in April" would be "*/3/tue/apr". NUMBER can also be negative, which means it is counted from the end of the month. "last Tuesday in April 2007" could be "2007/-1/tue/4"
  • DAYCODE => "mon", "tue", "wed", "thu", "fri", "sat", or "sun". Do not translate these words; use all lowercase.
  • MONCODE =>
    • MONTH
    • 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', or 'dec'. (not be translated; use all lowercase)
  • OFFSET =>
    • number (may be negative) that offsets the day determined by VALUE
    • DAYCODE (may be negative), the next DAYCODE that is either the same as this day, or the next(+)/prev(-) one.
    • "workday" or "weekend" (may be negative) - the next workday/weekend that is on this day, or the next/prev

Translations

Holiday entries are generally written for a specific country, and thus typcailly don't need to be written for more than one language. However, it might be appropriate to have your entries country name and holiday text be translated into the language that Gramps is running in. To make a country name or holiday name get translated, simply precede the name of the XML item with an underscore. For example:

  ...
  <country _name="Jewish Holidays">
    <date _name="Purim" value="> passover(y)" offset="-30"/>
    <date _name="Passover" value="> passover(y)" offset="0"/>
    ...
  </country>
  ...

In this example, "Jewish Holidays", "Purim", and "Passover" will be looked up in the Gramps gettext system for translations. If you would like to help add those translations, please see Translating Gramps.

Examples

<?xml version="1.0" encoding="UTF-8"?>
<calendar>
  <country name="United States">
    <date name="Daylight Saving Time begins" value="> dst(y)[0]" type="informational" />
    <date name="Daylight Saving Time ends" value="> dst(y)[1]" type="informational" />
    <date name="New Year's Day" value="*/1/1" type="national" />
    <date name="Labor Day" value="*/1/mon/sep" type="national" />
    <date name="Thanksgiving" value="*/4/thu/nov" type="national" />
    <date name="Inauguration Day" value="*/1/20" if="(y - 1980) % 4 == 0"  type="national" />
    <date name="Washington's Birthday" value="*/3/mon/feb" type="secular" />
    <date name="St. Patrick's Day" value="*/3/17" type="secular" />
    <date name="Assistants' Day" value="*/-1/sat/apr" offset="-3" type="secular" />
    <date name="Arbor Day" value="*/-1/fri/apr" type="secular" />
    <date name="Mothers' Day" value="*/2/sun/may" type="secular" />
    <date name="Fathers' Day" value="*/3/sun/jun" type="secular" />
    <date name="ML Kings's Birthday" value="*/3/mon/jan"  type="secular" />
    <date name="Memorial Day" value="*/-1/mon/may" type="secular" />
    <date name="Easter" value="> easter(y)" type="religious" />
    <date name="Ash Wednesday" value="> easter(y)" offset="-46" type="religious" />
   </country>
  <country name="China">
    <date name="Chinese New Year" value="2006/1/29" type="national" />
  </country>
  <country name="Finland">
    <date name="Card Night" value="*/-1/thu/*" type="personal" />
  </country>
</calendar>

The last set will only load if your country is Finland. It says that Card Night is the last Thursday of every month, every year. Let's play!

Note that you can have two separate holidays.xml files: one where Gramps is installed, and one in your personal .gramps/plugins/ folder.