BE to AD               package:epicalc               R Documentation

_C_h_a_n_g_e _y_e_a_r _i_n _B._E. _t_o _A._D.

_D_e_s_c_r_i_p_t_i_o_n:

     Subtracting 543 from year of a Date vector.

_U_s_a_g_e:

     be2ad(Date.in.BE)

_A_r_g_u_m_e_n_t_s:

Date.in.BE: an object of 'Date' class

_D_e_t_a_i_l_s:

     This function may be useful in countries where dates are (wrongly)
     commonly entered in the Buddhist Era (BE). The function subtracts
     543 from the year component of the argument 'Date.in.BE'. See
     'note' below.

_N_o_t_e:

     Although this function is useful in converting dates in BE to AD,
     there is still a serious limitation. 

     All computers validate a date field based on the Gregorian
     calendar (AD). Since AD is BE less 543 years and the leap year is
     always with AD being a multiple of 4 (and not a multiple of 100,
     except if it is a multiple of 400), the computer will return an
     invalid date for any record with 29 February and the year in BE.
     Thus, any candidate dataset for this function should not have any
     date of 29 February. The function be2ad *cannot* retrospectively
     solve this problem. 

     If a user wants to enter data using BE, the above limitation can
     only be overcome by separating the three fields of BE year, month
     and day during data entry and then using either the existing data
     entry software, such as Epidata, or a statistical software, such
     as R, to change BE years to AD years before incorporating them
     into a new date variable. Thus, this date variable would have year
     in AD only and will not need be2ad. In order to display the
     correct date variable in BE format, locale must be in Thai and
     appropriate format must be chosen. See example.

     Despite the above limitation, this function is kept in Epicalc.
     The reason is that there would still be a lot of (those type of
     faulty) datasets around in the countries that use BE that require
     changing BE to AD before any analysis of date variables can
     proceed. In doing so, the analyst must be aware of this potential
     problem in the dataset. It is advisable to check the data first to
     see whether there are any dates that fall on 29 February.

_A_u_t_h_o_r(_s):

     Virasakdi Chongsuvivatwong <cvirasak@medicine.psu.ac.th>

_E_x_a_m_p_l_e_s:

     Date1 <- as.Date("2543-2-28")
     be2ad(Date1)

     ## Not run:
     ## One would never have to

     # be2ad(as.Date("2551-2-29"))

     ## because as.Date("2551-2-29") is an invalid Date
     ## End(Not run)

     # To display date and time in BE under Thai Window OS
     format(Sys.Date(), "%x")
     format(Sys.time(), "%c")

