Monday, June 19, 2017

add holidays to gcal

add cambodian holiday to gcal

1- add source to apt sources.list
deb-src http://us.archive.ubuntu.com/ubuntu/ zesty main restricted universe multiverse
deb-src http://us.archive.ubuntu.com//ubuntu/ zesty-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com//ubuntu/ zesty-updates main restricted universe multiverse
deb-src http://us.archive.ubuntu.com//ubuntu/ zesty-security main restricted universe multiverse


2- download gcal source
$ sudo apt-get update
$ apt-get source gcal

3- modified the following files:
- src/hd-data3.c
 line: 3131 to 3189

{
  register int day;
  register int dayking;
  register int daywater;
  register int daynewyear;
  register int daychhum;
  register int i;


  ptr_cc_id = "KH";
  use_other_cc = !use_other_cc;
  chinese_hdy (init_data, detected, year, hd_elems, fday, count, ptr_cc_id,
           FALSE);
  use_other_cc = !use_other_cc;
  holiday (*init_data, detected,
       _(hd_text[HD_PARIS_PEACE_AGREEMENT_DAY].ht_text), ptr_cc_id, "+",
       23, 10, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_CHILDRENS_DAY].ht_text),
       ptr_cc_id, "+", DAY_MIN, 6, year, hd_elems, fday, count);
  holiday (*init_data, detected,
       _(hd_text[HD_CONSTITUTION_ANNIVERSARY].ht_text), ptr_cc_id, "+",
       24, 9, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_HUMAN_RIGHTS_DAY].ht_text),
       ptr_cc_id, "+", 10, MONTH_MAX, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_INDEPENDENCE_DAY].ht_text),
       ptr_cc_id, "+", 9, 11, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_COMMERORATION].ht_text),
       ptr_cc_id, "+", 16, 10, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_ROYAL_PLOUGHING].ht_text),
       ptr_cc_id, "+", 15, 5, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_VISAK_BOCHEA].ht_text),
       ptr_cc_id, "+", 10, 5, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_MEAK_BOCHEA].ht_text),
       ptr_cc_id, "+", 11, 2, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_7_MAKARA].ht_text),
       ptr_cc_id, "+", 7, 1, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_CORONATION_DAY].ht_text),
       ptr_cc_id, "+", 30, 10, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_LABOUR_DAY].ht_text), ptr_cc_id,
       "+", DAY_MIN, 5, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_NEW_YEARS_DAY].ht_text),
       ptr_cc_id, "+", DAY_MIN, MONTH_MIN, year, hd_elems, fday, count);
  dayking = day_of_year (13, 5, year);
  daychhum = day_of_year (19, 9, year);
  daynewyear = day_of_year (14, 4, year);
  daywater = day_of_year (2, 11, year);
  for (i = 0; i < 4; i++)
    holiday (*init_data, detected, _(hd_text[HD_THE_KINGS_BIRTHDAY].ht_text),
         ptr_cc_id, "+", dayking + i, 0, year, hd_elems, fday, count);
  for (i = 0; i < 4; i++)
    holiday (*init_data, detected, _(hd_text[HD_KHMER_NEW_YEAR].ht_text),
         ptr_cc_id, "+", daynewyear + i, 0, year, hd_elems, fday, count);
  for (i = 0; i < 3; i++)
    holiday (*init_data, detected, _(hd_text[HD_WATER_FESTIVAL].ht_text),
         ptr_cc_id, "+", daywater + i, 0, year, hd_elems, fday, count);
  for (i = 0; i < 3; i++)
    holiday (*init_data, detected, _(hd_text[HD_PCHHUM_BEN].ht_text),
         ptr_cc_id, "+", daychhum + i, 0, year, hd_elems, fday, count);
  holiday (*init_data, detected, _(hd_text[HD_WOMENS_DAY].ht_text),
       ptr_cc_id, "+", 8, 3, year, hd_elems, fday, count);

}

--- extract only that portion
$ cat src/hd-data3.c | sed -n -e 3129,3189p

- src/hd-data3.c
 line: 1018 to1027
  {HD_DAY_OF_CZECH_STATEHOOD, N_("Day of Czech Statehood")},
  {HD_7_MAKARA, N_("Victory day over genocide")},
  {HD_MEAK_BOCHEA, N_("MEAK BOCHEA")},
  {HD_KHMER_NEW_YEAR, N_("Khmer new year")},
  {HD_VISAK_BOCHEA, N_("Visak bochea")},
  {HD_ROYAL_PLOUGHING, N_("Royal ploughing")},
  {HD_PCHHUM_BEN, N_("pchhum ben ")},
  {HD_COMMERORATION, N_("Commeroration day")},
  {HD_WATER_FESTIVAL, N_("Water festival")}

#endif    /* !HD_TOP20CC */
};

- and  src/hd-defs.h
 line: 657 to 666
# define HD_7_MAKARA             552
# define HD_MEAK_BOCHEA             553
# define HD_KHMER_NEW_YEAR            554
# define HD_VISAK_BOCHEA           555
# define HD_ROYAL_PLOUGHING           556
# define HD_PCHHUM_BEN          557
# define HD_COMMERORATION         558
# define HD_WATER_FESTIVAL         559

# endif    /* !HD_TOP20CC */


4- compile
$ ./configure --prefix=`pwd`/output/
$  make
$ make installl

5- usages
- get list of holiday
$ ./gcal -H '\e[34m:\e[0m:\e[32m:\e[0m' -q KH -n

Eternal holiday list:                      The year 2017 is NO leap year

New Year's Day (KH)                      + Sun, Jan   1st 2017 = -169 days
Victory day over genocide (KH)           + Sat, Jan   7th 2017 = -163 days
Chinese New Year's Day 4654-6 (KH)       * Sat, Jan  28th 2017 = -142 days
MEAK BOCHEA (KH)                         + Sat, Feb  11th 2017 = -128 days
Women's Day (KH)                         + Wed, Mar   8th 2017 = -103 days
Khmer new year (KH)                      + Fri, Apr  14th 2017 =  -66 days
Khmer new year (KH)                      + Sat, Apr  15th 2017 =  -65 days
Khmer new year (KH)                      + Sun, Apr  16th 2017 =  -64 days
Khmer new year (KH)                      + Mon, Apr  17th 2017 =  -63 days
Labour Day (KH)                          + Mon, May   1st 2017 =  -49 days
Visak bochea (KH)                        + Wed, May  10th 2017 =  -40 days
The King's Birthday (KH)                 + Sat, May  13th 2017 =  -37 days
The King's Birthday (KH)                 + Sun, May  14th 2017 =  -36 days
Royal ploughing (KH)                     + Mon, May  15th 2017 =  -35 days
The King's Birthday (KH)                 + Mon, May  15th 2017 =  -35 days
The King's Birthday (KH)                 + Tue, May  16th 2017 =  -34 days
Children's Day (KH)                      + Thu, Jun   1st 2017 =  -18 days
pchhum ben  (KH)                         + Tue, Sep  19th 2017 =  +92 days
pchhum ben  (KH)                         + Wed, Sep  20th 2017 =  +93 days
pchhum ben  (KH)                         + Thu, Sep  21st 2017 =  +94 days
Constitution Anniversary (KH)            + Sun, Sep  24th 2017 =  +97 days
Commeroration day (KH)                   + Mon, Oct  16th 2017 = +119 days
Paris Peace Agreement Day (KH)           + Mon, Oct  23rd 2017 = +126 days
Coronation Day (KH)                      + Mon, Oct  30th 2017 = +133 days
Water festival (KH)                      + Thu, Nov   2nd 2017 = +136 days
Water festival (KH)                      + Fri, Nov   3rd 2017 = +137 days
Water festival (KH)                      + Sat, Nov   4th 2017 = +138 days
Independence Day (KH)                    + Thu, Nov   9th 2017 = +143 days
Human Rights Day (KH)                    + Sun, Dec  10th 2017 = +174 days


- get 2017 calendar,
$ ./gcal -H '\e[34m:\e[0m:\e[32m:\e[0m' -q KH 2017 



-get  us ak state calendar 2017
$ ./gcal -H '\e[34m:\e[0m:\e[32m:\e[0m' -q US_AK 2017                           

No comments:

Post a Comment