function test_parseEpoch() { Debug::text('Testing Date Parsing of EPOCH!', __FILE__, __LINE__, __METHOD__, 10); TTDate::setDateFormat('m-d-y'); TTDate::setTimeZone('PST'); TTDate::setTimeFormat('g:i A'); $this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400); TTDate::setDateFormat('Y-m-d'); TTDate::setTimeZone('PST'); TTDate::setTimeFormat('g:i A'); $this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400); $this->assertEquals(TTDate::parseDateTime(600), (int) 600); //Test small epochs that may conflict with 24hr time that just has the time and not a date. $this->assertEquals(TTDate::parseDateTime(1800), (int) 1800); //Test small epochs that may conflict with 24hr time that just has the time and not a date. $this->assertEquals(TTDate::parseDateTime(-600), (int) -600); //Test small epochs that may conflict with 24hr time that just has the time and not a date. $this->assertEquals(TTDate::parseDateTime(-1800), (int) -1800); //Test small epochs that may conflict with 24hr time that just has the time and not a date. }
function test_parseEpoch() { Debug::text('Testing Date Parsing of EPOCH!', __FILE__, __LINE__, __METHOD__, 10); TTDate::setDateFormat('m-d-y'); TTDate::setTimeZone('PST'); TTDate::setTimeFormat('g:i A'); $this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400); TTDate::setDateFormat('Y-m-d'); TTDate::setTimeZone('PST'); TTDate::setTimeFormat('g:i A'); $this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400); }
function parse_time_stamp($input, $default_value = NULL, $parse_hint = NULL) { //Use this to manually force a specific timezone. //TTDate::setTimeZone('GMT'); if (strpos($parse_hint, '#') !== FALSE) { $split_parse_hint = explode('#', $parse_hint); } if (isset($split_parse_hint[0]) and $split_parse_hint[0] != '') { TTDate::setDateFormat($split_parse_hint[0]); } if (isset($split_parse_hint[1]) and $split_parse_hint[1] != '') { TTDate::setTimeFormat($split_parse_hint[1]); } else { TTDate::setTimeFormat('g:i A'); } return TTDate::parseDateTime($input); }
function _postParseRow($row_number, $raw_row) { $raw_row['user_id'] = $this->getUserIdByRowData($raw_row); if ($raw_row['user_id'] == FALSE) { unset($raw_row['user_id']); } //Combine date/time columns together and convert all time_stamp columns into epochs. $column_map = $this->getColumnMap(); //Include columns that should always be there. //Handle one punch per row. if (isset($column_map['time_stamp'])) { Debug::Text('Parsing time_stamp column...', __FILE__, __LINE__, __METHOD__, 10); $date_time_format = $column_map['time_stamp']['parse_hint'] . '_' . $column_map['time_stamp']['parse_hint']; } elseif (!isset($column_map['time_stamp']) and isset($column_map['date']) and isset($column_map['time'])) { Debug::Text('Parsing date/time column...', __FILE__, __LINE__, __METHOD__, 10); //$raw_row['time_stamp'] = $raw_row[$column_map['date']['map_column_name']].' '. $raw_row[$column_map['time']['map_column_name']]; $raw_row['time_stamp'] = $raw_row['date'] . ' ' . $raw_row['time']; $date_time_format = $column_map['date']['parse_hint'] . '_' . $column_map['time']['parse_hint']; unset($raw_row['date'], $raw_row['time']); } else { $date_time_format = 'd-M-y_g:i A T'; } if (isset($raw_row['time_stamp'])) { $split_date_time_format = explode('_', $date_time_format); //Debug::Arr($split_date_time_format, 'Date/Time Format: '. $date_time_format, __FILE__, __LINE__, __METHOD__,10); TTDate::setDateFormat($split_date_time_format[0]); TTDate::setTimeFormat($split_date_time_format[1]); $raw_row['time_stamp'] = TTDate::parseDateTime($raw_row['time_stamp']); } //Debug::Arr($column_map, 'Column Map', __FILE__, __LINE__, __METHOD__,10); //Debug::Arr($raw_row, 'Raw Row', __FILE__, __LINE__, __METHOD__,10); //Handle two punches per row. if (isset($column_map['in_time_stamp']) and isset($column_map['out_time_stamp'])) { Debug::Text('Parsing Two punches per row...', __FILE__, __LINE__, __METHOD__, 10); $in_date_time_format = $column_map['in_time_stamp']['parse_hint'] . '_' . $column_map['in_time_stamp']['parse_hint']; $out_date_time_format = $column_map['out_time_stamp']['parse_hint'] . '_' . $column_map['out_time_stamp']['parse_hint']; unset($raw_row['status'], $raw_row['type']); } elseif (!isset($column_map['in_time_stamp']) and !isset($column_map['out_time_stamp']) and isset($column_map['in_punch_date']) and isset($column_map['in_punch_time']) and isset($column_map['out_punch_date']) and isset($column_map['out_punch_time'])) { Debug::Text('Parsing Two punches per row with separte date/time columns...', __FILE__, __LINE__, __METHOD__, 10); $raw_row['in_time_stamp'] = $raw_row['in_punch_date'] . ' ' . $raw_row['in_punch_time']; $in_date_time_format = $column_map['in_punch_date']['parse_hint'] . '_' . $column_map['in_punch_time']['parse_hint']; unset($raw_row['in_punch_date'], $raw_row['in_punch_time']); $raw_row['out_time_stamp'] = $raw_row['out_punch_date'] . ' ' . $raw_row['out_punch_time']; $out_date_time_format = $column_map['out_punch_date']['parse_hint'] . '_' . $column_map['out_punch_time']['parse_hint']; unset($raw_row['out_punch_date'], $raw_row['out_punch_time']); unset($raw_row['status'], $raw_row['type']); } else { $in_date_time_format = $out_date_time_format = $date_time_format = 'd-M-y_g:i A T'; } if (isset($raw_row['in_time_stamp']) and isset($raw_row['out_time_stamp'])) { Debug::Text('bParsing Two punches per row...', __FILE__, __LINE__, __METHOD__, 10); $split_in_date_time_format = explode('_', $in_date_time_format); TTDate::setDateFormat($split_in_date_time_format[0]); TTDate::setTimeFormat($split_in_date_time_format[1]); $raw_row['in_time_stamp'] = TTDate::parseDateTime($raw_row['in_time_stamp']); $split_out_date_time_format = explode('_', $out_date_time_format); TTDate::setDateFormat($split_out_date_time_format[0]); TTDate::setTimeFormat($split_out_date_time_format[1]); $raw_row['out_time_stamp'] = TTDate::parseDateTime($raw_row['out_time_stamp']); } if (!isset($raw_row['in_type']) and !isset($raw_row['out_type']) and !isset($raw_row['type']) and (!isset($raw_row['type_id']) or isset($raw_row['type_id']) and $raw_row['type_id'] == '')) { Debug::Text('Defaulting to normal punch type...', __FILE__, __LINE__, __METHOD__, 10); $raw_row['type_id'] = 10; //Normal } if (!isset($raw_row['in_status']) and !isset($raw_row['out_status']) and !isset($raw_row['status']) and (!isset($raw_row['status_id']) or isset($raw_row['status_id']) and $raw_row['status_id'] == '')) { Debug::Text('Defaulting to IN punch status...', __FILE__, __LINE__, __METHOD__, 10); $raw_row['status_id'] = 10; //IN } if ($this->getImportOptions('disable_rounding') == TRUE) { $raw_row['disable_rounding'] = TRUE; } unset($raw_row['date'], $raw_row['time']); Debug::Arr($raw_row, 'postParse Row: ', __FILE__, __LINE__, __METHOD__, 10); return $raw_row; }
function testBiWeeklyC() { // Anchor: 01-Nov-04 // Primary: 15-Nov-04 // Primary Trans: 22-Nov-04 // Secondary: 29-Nov-04 // Secondary Trans: 06-Dec-04 $ret_obj = $this->createPayPeriodSchedule(20, 1, 0, NULL, NULL, NULL, NULL, TRUE); Debug::text('Pay Period Schedule ID: ' . $ret_obj->getId(), __FILE__, __LINE__, __METHOD__, 10); TTDate::setTimeFormat('g:i A T'); $ret_obj->getNextPayPeriod(strtotime('03-Dec-06')); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '04-Dec-06 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '17-Dec-06 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '17-Dec-06', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 25, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '18-Dec-06 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '31-Dec-06 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '31-Dec-06', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 26, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '01-Jan-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '14-Jan-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '14-Jan-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 1, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '15-Jan-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '28-Jan-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '28-Jan-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 2, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '29-Jan-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '11-Feb-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '11-Feb-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 3, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '12-Feb-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '25-Feb-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '25-Feb-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 4, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '26-Feb-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '11-Mar-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '11-Mar-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 5, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '12-Mar-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '25-Mar-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '25-Mar-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 6, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '26-Mar-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '08-Apr-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '08-Apr-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 7, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '09-Apr-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '22-Apr-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '22-Apr-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 8, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '23-Apr-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '06-May-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '06-May-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 9, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '07-May-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '20-May-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '20-May-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 10, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '21-May-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '03-Jun-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '03-Jun-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 11, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '04-Jun-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '17-Jun-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '17-Jun-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 12, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '18-Jun-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '01-Jul-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '01-Jul-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 13, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '02-Jul-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '15-Jul-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '15-Jul-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 14, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '16-Jul-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '29-Jul-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '29-Jul-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 15, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '30-Jul-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '12-Aug-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '12-Aug-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 16, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '13-Aug-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '26-Aug-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '26-Aug-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 17, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '27-Aug-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '09-Sep-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '09-Sep-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 18, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '10-Sep-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '23-Sep-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '23-Sep-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 19, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '24-Sep-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '07-Oct-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '07-Oct-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 20, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '08-Oct-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '21-Oct-07 11:59 PM PDT', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '21-Oct-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 21, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '22-Oct-07 12:00 AM PDT', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '04-Nov-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '04-Nov-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 22, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '05-Nov-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '18-Nov-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '18-Nov-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 23, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '19-Nov-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '02-Dec-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '02-Dec-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 24, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '03-Dec-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '16-Dec-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '16-Dec-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 25, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '17-Dec-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '30-Dec-07 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '30-Dec-07', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 26, '1- Pay Period Number'); $ret_obj->getNextPayPeriod($next_end_date); $next_end_date = $ret_obj->getNextEndDate(); $this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '31-Dec-07 12:00 AM PST', '1- Start Date'); $this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '13-Jan-08 11:59 PM PST', '1- End Date'); $this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '13-Jan-08', '1- Transaction Date'); $this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 1, '1- Pay Period Number'); }
function setDateTimePreferences() { //TTDate::setTimeZone( $this->getTimeZone() ); if ($this->setTimeZonePreferences() == FALSE) { //In case setting the time zone failed, most likely due to MySQL timezone issues. return FALSE; } TTDate::setDateFormat($this->getDateFormat()); TTDate::setTimeFormat($this->getTimeFormat()); TTDate::setTimeUnitFormat($this->getTimeUnitFormat()); return TRUE; }