From 48792cb66224c582007152b4dc59573d4d376b2f Mon Sep 17 00:00:00 2001 From: dieghernan Date: Thu, 25 May 2017 09:06:57 +0200 Subject: [PATCH] v7.1 Improvements on Norge --- package.json | 30 +++++++++--------- src/c/main.c | 5 ++- src/c/num2words-nn.c | 73 +++++++++++++++++++++++++++++++++++++++++--- src/c/num2words-nn.h | 1 + src/pkjs/config.js | 3 +- 5 files changed, 91 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 35d4e60..34f32ef 100644 --- a/package.json +++ b/package.json @@ -56,17 +56,15 @@ { "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Light.otf", - "name": "FONT_GLIGHT_30", + "name": "FONT_GLIGHT_22", "targetPlatforms": null, - "trackingAdjust": -2, "type": "font" }, { - "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", + "characterRegex": "[a-z .' A-Z 0-9 \u00e4\u00e1\u00e9\u00ed\u00f3\u00fa\u00f6\u00fc\u00fb\u00ea \u00e5\u00f8\u016d]", "file": "fonts/Gotham Light.otf", - "name": "FONT_GLIGHT_34", + "name": "FONT_GLIGHT_16", "targetPlatforms": null, - "trackingAdjust": -2, "type": "font" }, { @@ -78,29 +76,33 @@ "type": "font" }, { - "characterRegex": "[a-z .' A-Z 0-9 \u00e4\u00e1\u00e9\u00ed\u00f3\u00fa\u00f6\u00fc\u00fb\u00ea \u00e5\u00f8\u016d]", + "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Light.otf", - "name": "FONT_GLIGHT_16", + "name": "FONT_GLIGHT_34", "targetPlatforms": null, + "trackingAdjust": -2, "type": "font" }, { "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Light.otf", - "name": "FONT_GLIGHT_22", + "name": "FONT_GLIGHT_30", "targetPlatforms": null, + "trackingAdjust": -2, "type": "font" }, { + "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Bold.otf", - "name": "FONT_GBOLD_16", + "name": "FONT_GBOLD_22", "targetPlatforms": null, + "trackingAdjust": -1, "type": "font" }, { "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Bold.otf", - "name": "FONT_GBOLD_39", + "name": "FONT_GBOLD_30", "targetPlatforms": null, "trackingAdjust": -1, "type": "font" @@ -116,17 +118,15 @@ { "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Bold.otf", - "name": "FONT_GBOLD_30", + "name": "FONT_GBOLD_39", "targetPlatforms": null, "trackingAdjust": -1, "type": "font" }, { - "characterRegex": "[a-z ' UV\u00f6\u00fc\u00e9\u00fb\u00ea\u016d \\-\u00e5\u00e4\u00f8]", "file": "fonts/Gotham Bold.otf", - "name": "FONT_GBOLD_22", + "name": "FONT_GBOLD_16", "targetPlatforms": null, - "trackingAdjust": -1, "type": "font" }, { @@ -150,5 +150,5 @@ "watchface": true } }, - "version": "7.0.0" + "version": "7.1.0" } diff --git a/src/c/main.c b/src/c/main.c index f6bfed1..8e5f984 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -109,6 +109,9 @@ void writetimeto3words(int hour_i,int minute_i,int *linebold_i,char *line1_i, ch else if (lang_i==7){ //Norwegian time_to_3words_NN(hour_i , minute_i,linebold_i ,line1_i, line2_i, line3_i); } + else if (lang_i==71){ //Norwegian Colloquial + time_to_3words_NN2(hour_i , minute_i,linebold_i ,line1_i, line2_i, line3_i); + } else if (lang_i==8){ //Danish time_to_3words_DK(hour_i , minute_i,linebold_i ,line1_i, line2_i, line3_i); } @@ -144,7 +147,7 @@ void writedatelang(int week,int Mon,int Day, char* iterwd,char * iterdat, char * else if (Lang==6){ //Italian WriteDate_IT(week , Mon ,Day, iterwd ,iterdat,itermon); } - else if (Lang==7){ //Norwegian + else if (Lang==7 || Lang==71){ //Norwegian WriteDate_NN(week , Mon ,Day, iterwd ,iterdat,itermon); } else if (Lang==8){ //Danish diff --git a/src/c/num2words-nn.c b/src/c/num2words-nn.c index e6164ac..7653814 100644 --- a/src/c/num2words-nn.c +++ b/src/c/num2words-nn.c @@ -18,6 +18,19 @@ static const char* const HOUR_NN[] = { "tolv", "ett" }; +static const char* const MIN_NN_C[]={ + "", + "en", + "to", + "tre", + "fire", + "fem", + "seks", + "sju", + "åtte", + "ni", + "ti" +}; static const char* const MIN_NN1[]={ "klokka er", "ett", @@ -34,7 +47,19 @@ static const char* const MIN_NN1[]={ "tolv", "tretten", "fjorten", - "kvart" + "kvart", + "seksten", + "sytten", + "atten", + "nitten" +}; +static const char* const MIN_NNAUX[] = { + "null", + "", + "tjue", + "tretti", + "førti", + "femti" }; //Init_StrMonthDat: Create strings for Months and Days const char* const MONTHS_NN[] = { @@ -62,10 +87,12 @@ const char* const WEEKDAY_NN[] = { }; //End_Weekday void time_to_3words_NN(int hours, int minutes, int *LineBold,char *line1, char *line2, char *line3){ - //Clean line3 at init + //Clean lines at init + strcpy(line1,""); + strcpy(line2, ""); strcpy(line3, ""); //shift 1 hour the label for this minutes - if ( minutes>15) {hours=(hours+1);} + if ( minutes>=20) {hours=(hours+1);} //Exceptions first hours=hours % 12; if (minutes==0 || minutes==30){ @@ -79,7 +106,7 @@ void time_to_3words_NN(int hours, int minutes, int *LineBold,char *line1, char * *LineBold=2; } else { - if (minutes<=15){ + if (minutes<=19){ strcpy(line1,MIN_NN1[minutes]); strcpy(line2,"over"); } @@ -99,6 +126,44 @@ void time_to_3words_NN(int hours, int minutes, int *LineBold,char *line1, char * *LineBold=3; } } +void time_to_3words_NN2(int hours, int minutes, int *LineBold,char *line1, char *line2, char *line3){ + //Clean lines at init + strcpy(line1,""); + strcpy(line2, ""); + strcpy(line3, ""); + //Line 1 is always hour except at oclock + hours=hours % 12; + if (minutes==0){ + strcpy(line1,MIN_NN1[minutes]); + strcpy(line2,HOUR_NN[hours]); + *LineBold=2; + strcpy(line3,""); + } + else { + strcpy(line1, HOUR_NN[hours]); + *LineBold=1; + //Line2 + if (minutes<10){ + strcpy(line2,MIN_NNAUX[0]); + } + else if (minutes>=20){ + strcpy(line2,MIN_NNAUX[minutes/10]); + } + else if (minutes==15){ + strcpy(line2,"femten"); + } + else { + strcpy(line2,MIN_NN1[minutes]); + } + //Line3 + if (minutes%10==0){ + strcpy(line3,""); + } + else if (minutes<=9 || minutes>=20){ + strcpy(line3, MIN_NN_C[minutes%10]); + } + } +} void WriteDate_NN(int WD, int Mnth, int Dy, char *iterweekday, char *iterdate, char *itermonth ){ strcpy(iterweekday, WEEKDAY_NN[WD]); snprintf(iterdate, sizeof(iterdate), "%d.", Dy); diff --git a/src/c/num2words-nn.h b/src/c/num2words-nn.h index e7e9774..f6f32cb 100644 --- a/src/c/num2words-nn.h +++ b/src/c/num2words-nn.h @@ -1,4 +1,5 @@ #pragma once #include "string.h" void time_to_3words_NN(int hours, int minutes,int *LineBold, char *line1, char *line2, char *line3); +void time_to_3words_NN2(int hours, int minutes,int *LineBold, char *line1, char *line2, char *line3); void WriteDate_NN(int WD, int Mnth, int Dy, char *iterweekday, char *iterdate, char *itermonth ); \ No newline at end of file diff --git a/src/pkjs/config.js b/src/pkjs/config.js index 225e4cd..ba1bc94 100644 --- a/src/pkjs/config.js +++ b/src/pkjs/config.js @@ -36,6 +36,7 @@ module.exports = [ {"label":"Portuguese (Brazil)", "value": "5" }, {"label":"Italian", "value": "6" }, {"label":"Norwegian", "value": "7"}, + {"label":"Norwegian (colloquial)", "value": "71"}, {"label":"Danish", "value": "8"}, {"label":"Swedish", "value": "9"}, {"label":"Esperanto", "value": "10"}, @@ -187,7 +188,7 @@ module.exports = [ }, { "type": "heading", - "defaultValue": "Version v7.0", + "defaultValue": "Version v7.1", "size":6 } , {