<?php
########### Settings ###############
define ( 'OUTPUT_DIR', __DIR__
. '/data');
define ( 'OUTPUT_JSON', true );
define ( 'OUTPUT_SER', true );
define ( 'OUTPUT_BIGFILE', true );
define ( 'OUTPUT_SMALL_FILES', true );
## USE ONE OF THEM:
# Nice to show, but bigger Files:
#define ( 'JSON_OPTIONS', JSON_INVALID_UTF8_SUBSTITUTE | JSON_PRETTY_PRINT );
# Smaller Files:
define ( 'JSON_OPTIONS', JSON_INVALID_UTF8_SUBSTITUTE
);
########### PROGRAM ###############
$arLocales = explode( "\n", `locale
-a`
);
$types['types'][] = 'day_short';
$types['types'][] = 'day';
$types['types'][] = 'month_short';
$types['types'][] = 'month';
$types['types_reverse']['day_short'] = 0;
$types['types_reverse']['day'] = 1;
$types['types_reverse']['month_short'] = 2;
$types['types_reverse']['month'] = 3;
foreach ( $arLocales as $loci ) {
$y=2024; #2024 begins with monday
$m=1;
# to become a clear numbered array
$translations[$loci][0][0] = '';
$translations[$loci][1][0] = '';
for ( $d = 1; $d < 8; $d++ ) {
$strDate = "${y}-${m}-${d}";
$sys = "LANG=${loci} date +%a --date='${y}-${m}-${d}'";
$translations[$loci][0][$d] = trim( `
$sys`
);
$sys = "LANG=${loci} date +%A --date='${y}-${m}-${d}'";
$translations[$loci][1][$d] = trim( `
$sys`
);
}
# set sunday as day 7 and 0:
$translations[$loci][0][0] = $translations[$loci][0][7];
$translations[$loci][1][0] = $translations[$loci][1][7];
$d=1;
$translations[$loci][2][0] = false;
$translations[$loci][3][0] = false;
for ( $m = 1; $m < 13; $m++ ) {
$strDate = "${y}-${m}-${d}";
$sys = "LANG=${loci} date +%b --date='${y}-${m}-${d}'";
$translations[$loci][2][$m] = $str;
$sys = "LANG=${loci} date +%B --date='${y}-${m}-${d}'";
$translations[$loci][3][$m] = $str;
}
}
if ( OUTPUT_JSON ) {
trigger_error( OUTPUT_DIR
. '/_date_names_by_number.types.json NOT written or EMPTY.' );
}
}
if ( OUTPUT_SER ) {
trigger_error( OUTPUT_DIR
. '/_date_names_by_number.types.ser NOT written or EMPTY.' );
}
}
if ( OUTPUT_BIGFILE ) {
if ( OUTPUT_JSON ) {
trigger_error( OUTPUT_DIR
. '/date_names_by_number.json NOT written or EMPTY.' );
}
}
if ( OUTPUT_SER ) {
trigger_error( OUTPUT_DIR
. '/date_names_by_number.ser NOT written or EMPTY.' );
}
}
}
if ( OUTPUT_SMALL_FILES ) {
if ( OUTPUT_JSON ) {
trigger_error( OUTPUT_DIR
. '/date_names_by_number.locales.json NOT written or EMPTY.' );
}
}
if ( OUTPUT_SER ) {
trigger_error( OUTPUT_DIR
. '/date_names_by_number.locales.ser NOT written or EMPTY.' );
}
}
foreach ( $arLocales as $key ) {
if ( OUTPUT_JSON ) {
trigger_error( OUTPUT_DIR
. '/date_names_by_number_' . $key. '.json NOT written or EMPTY.' );
}
}
if ( OUTPUT_SER ) {
trigger_error( OUTPUT_DIR
. '/date_names_by_number_' . $key. '.ser NOT written or EMPTY.' );
}
}
}
}
if ( OUTPUT_JSON ) {
$sys= 'cd ' . OUTPUT_DIR . '; tar -czf _date_names_by_number_json.tar.gz *.json; ls -l _date_names_by_number_json.tar.gz';
echo `$sys`;
}
if ( OUTPUT_SER ) {
$sys= 'cd ' . OUTPUT_DIR . '; tar -czf _date_names_by_number_ser.tar.gz *.ser; ls -l _date_names_by_number_ser.tar.gz';
echo `$sys`;
}