daycounter functions rewritten using Rcpp Attributes