formats/time/m_mtzfile.c
/*! Parse our extended Posix TZ DST rule.
 * The extended rule is "year;start[/time],end[/time]"
 * \param rule The rule to parse
 * \param adjust The adjustment object for the DST rule.
 * \param offset The offset that applies when DST is in effect.
 * \return Success on success. Otherwise error condition.
 */
Parse our extended Posix TZ DST rule.
The extended rule is "year;start[/time],end[/time]"
\param rule The rule to parse
\param adjust The adjustment object for the DST rule.
\param offset The offset that applies when DST is in effect.
\return Success on success. Otherwise error condition.
Parse our extended Posix TZ DST rule . The extended rule is " year ; start [ / time ] end [ / time ] " \ param rule The rule to parse \ param adjust The adjustment object for the DST rule . \ param offset The offset that applies when DST is in effect . \ return Success on success . Otherwise error condition .
static M_time_result_t M_mtzfile_tz_parse_dst_adjust_rule(const char *rule, M_time_tz_dst_rule_t **adjust, M_time_t offset, M_time_t offset_dst)
{
	char            **parts;
	M_parser_t       *parser;
	M_parser_t      **adjust_parts;
	size_t            num_parts;
	size_t            num_adjust_parts;
	M_int64           year;
	M_time_result_t   res;
	if (rule == NULL || *rule == '\0')
		return M_TIME_RESULT_INVALID;
	parts = M_str_explode_str(';', rule, &num_parts);
	if (parts == NULL || num_parts != 2 || !M_str_isnum(parts[0])) {
		M_str_explode_free(parts, num_parts);
		return M_TIME_RESULT_YEAR;
	}
	parser       = M_parser_create_const((const unsigned char *)parts[1], M_str_len(parts[1]), M_PARSER_FLAG_NONE);
	adjust_parts = M_parser_split(parser, ',', 0, M_PARSER_SPLIT_FLAG_NONE, &num_adjust_parts);
	if (adjust_parts == NULL || num_adjust_parts != 2) {
		M_parser_split_free(adjust_parts, num_adjust_parts);
		M_parser_destroy(parser);
		M_str_explode_free(parts, num_parts);
		return M_TIME_RESULT_INVALID;
	}
	year = M_str_to_int32(parts[0]);
	res  = M_time_tz_posix_parse_dst_adjust_rule(adjust_parts[0], adjust_parts[1], adjust, year, offset, offset_dst);
	M_parser_split_free(adjust_parts, num_adjust_parts);
	M_parser_destroy(parser);
	M_str_explode_free(parts, num_parts);
	return res;
}
static M_time_result_t M_mtzfile_tz_parse_dst_adjust_rule ( const char * rule , M_time_tz_dst_rule_t * * adjust , M_time_t offset , M_time_t offset_dst ) { char * * parts ; M_parser_t * parser ; M_parser_t * * adjust_parts ; size_t num_parts ; size_t num_adjust_parts ; M_int64 year ; M_time_result_t res ; if ( rule == NULL || * rule == ' \0 ' ) return M_TIME_RESULT_INVALID ; parts = M_str_explode_str ( ' ' , rule , & num_parts ) ; if ( parts == NULL || num_parts != 2 || ! M_str_isnum ( parts [ 0 ] ) ) { M_str_explode_free ( parts , num_parts ) ; return M_TIME_RESULT_YEAR ; } parser = M_parser_create_const ( ( const unsigned char * ) parts [ 1 ] , M_str_len ( parts [ 1 ] ) , M_PARSER_FLAG_NONE ) ; adjust_parts = M_parser_split ( parser , ' ' , 0 , M_PARSER_SPLIT_FLAG_NONE , & num_adjust_parts ) ; if ( adjust_parts == NULL || num_adjust_parts != 2 ) { M_parser_split_free ( adjust_parts , num_adjust_parts ) ; M_parser_destroy ( parser ) ; M_str_explode_free ( parts , num_parts ) ; return M_TIME_RESULT_INVALID ; } year = M_str_to_int32 ( parts [ 0 ] ) ; res = M_time_tz_posix_parse_dst_adjust_rule ( adjust_parts [ 0 ] , adjust_parts [ 1 ] , adjust , year , offset , offset_dst ) ; M_parser_split_free ( adjust_parts , num_adjust_parts ) ; M_parser_destroy ( parser ) ; M_str_explode_free ( parts , num_parts ) ; return res ; }
Parse our extended Posix TZ DST rule.
Parse our extended Posix TZ DST rule .
/* Split the year from the DST rule. */