Example #1
0
ERL_NIF_TERM calendar_locales(ErlNifEnv* env, int argc, 
    const ERL_NIF_TERM /*argv*/[])
{
    if (argc != 0)
        return enif_make_badarg(env);

    return generate_available(env, ucal_getAvailable, 
            ucal_countAvailable());
}
Example #2
0
int i18n_string_load(ErlNifEnv *env, void ** /*priv_data*/, 
    ERL_NIF_TERM /*load_info*/)
{
    ErlNifResourceFlags flags = (ErlNifResourceFlags)(ERL_NIF_RT_CREATE |
        ERL_NIF_RT_TAKEOVER);

    iterator_type = enif_open_resource_type(env, NULL, "iterator_type",
        iterator_dtor, flags, NULL); 

    if (iterator_type == NULL) return 1;

    global_string_env = enif_alloc_env();

    available_locales = generate_available(global_string_env, 
        ubrk_getAvailable, ubrk_countAvailable());

    return 0;
}
Example #3
0
int i18n_date_load(ErlNifEnv *env, void ** /*priv_data*/, 
    ERL_NIF_TERM /*load_info*/)
{
    ErlNifResourceFlags flags = (ErlNifResourceFlags)(ERL_NIF_RT_CREATE |
        ERL_NIF_RT_TAKEOVER);

    calendar_type = enif_open_resource_type(env, NULL, "calendar_type",
        calendar_dtor, flags, NULL); 
    if (calendar_type == NULL) return 6;

    int i = 0;
    int f;
    for (; i < UCAL_FIELD_COUNT; i++)
        field_to_pos[i] = -1;

    /* SELECT * FROM types ORDER BY duration DESC, max_count DESC; */

    i = 0;
    f = UCAL_ERA; 
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    /* Use UCAL_EXTENDED_YEAR instead of UCAL_YEAR */
    f = UCAL_EXTENDED_YEAR;
    pos_to_field[i] = f;
    field_to_pos[f] = i;

    f = UCAL_YEAR;
    field_to_pos[f] = i;
    i++;

    f = UCAL_MONTH;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_WEEK_OF_MONTH;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;


    f = UCAL_WEEK_OF_YEAR;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_DAY_OF_WEEK;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_DAY_OF_MONTH;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_DAY_OF_YEAR;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_AM_PM;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_HOUR_OF_DAY;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_HOUR;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_MINUTE;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_SECOND;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_MILLISECONDS_IN_DAY;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;

    f = UCAL_MILLISECOND;
    pos_to_field[i] = f;
    field_to_pos[f] = i;
    i++;
    
    POS_MAX = i;


//  [UCAL_DAY_OF_WEEK_IN_MONTH] = i++;



    global_date_env = enif_alloc_env();
    available_locales = generate_available(global_date_env, 
        ucal_getAvailable, ucal_countAvailable());

    available_timezones = get_timezone_ids(env);
    available_timezones = reverse_list(env, available_timezones);
    available_timezones = enif_make_copy(global_date_env, available_timezones);



    return 0;
}