]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add timezone support to mod_say_{de,es,ja,nl,th,zh}
authorHristo Trendev <htrendev@gmail.com>
Tue, 2 Dec 2014 16:08:12 +0000 (17:08 +0100)
committerHristo Trendev <htrendev@gmail.com>
Tue, 2 Dec 2014 16:08:12 +0000 (17:08 +0100)
This is nothing more than a shameless copy/paste from another mod_say
module, which already had timezone support. It simply checks if the
timezone variable is set and if it contains a valid timezone, then this
timezone will be used when announcing times/dates.

FS-7048 #resolve

src/mod/say/mod_say_de/mod_say_de.c
src/mod/say/mod_say_es/mod_say_es.c
src/mod/say/mod_say_ja/mod_say_ja.c
src/mod/say/mod_say_nl/mod_say_nl.c
src/mod/say/mod_say_th/mod_say_th.c
src/mod/say/mod_say_zh/mod_say_zh.c

index 2116942ca2833633b392123c8fcc40d1cc51e900..00af9dd1fe20dce43cdda4d37bd4fed4a41c7978 100644 (file)
@@ -226,6 +226,8 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
        switch_time_t target = 0;
        switch_time_exp_t tm;
        uint8_t say_date = 0, say_time = 0;
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       const char *tz = switch_channel_get_variable(channel, "timezone");
 
        if (say_args->type == SST_TIME_MEASUREMENT) {
                int64_t hours = 0;
@@ -314,7 +316,18 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
        } else {
                target = switch_micro_time_now();
        }
-       switch_time_exp_lt(&tm, target);
+
+       if (tz) {
+               int check = atoi(tz);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+               if (check) {
+                       switch_time_exp_tz(&tm, target, check);
+               } else {
+                       switch_time_exp_tz_name(tz, &tm, target);
+               }
+       } else {
+               switch_time_exp_lt(&tm, target);
+       }
 
        switch (say_args->type) {
        case SST_CURRENT_DATE_TIME:
index efda97b46890389ae4a4ab73f611e1d3a106e8c8..8de56e861e14c6a3b973b5473a3cb6a6aac4d108 100644 (file)
@@ -220,6 +220,8 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
        switch_time_t target = 0;
        switch_time_exp_t tm;
        uint8_t say_date = 0, say_time = 0;
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       const char *tz = switch_channel_get_variable(channel, "timezone");
 
        if (say_args->type == SST_TIME_MEASUREMENT) {
                int64_t hours = 0;
@@ -304,7 +306,18 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
        } else {
                target = switch_micro_time_now();
        }
-       switch_time_exp_lt(&tm, target);
+
+       if (tz) {
+               int check = atoi(tz);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+               if (check) {
+                       switch_time_exp_tz(&tm, target, check);
+               } else {
+                       switch_time_exp_tz_name(tz, &tm, target);
+               }
+       } else {
+               switch_time_exp_lt(&tm, target);
+       }
 
        switch (say_args->type) {
        case SST_CURRENT_DATE_TIME:
index 76d2ac69f918616b65dbdaf8c5b1c7c0b7d004ce..72c7c38131b1f43eb8edc16ec96e38a1b6321236 100644 (file)
@@ -248,6 +248,8 @@ static switch_status_t ja_say_time(switch_core_session_t *session, char *tosay,
        switch_time_exp_t tm;
        uint8_t say_date = 0;
        uint8_t say_time = 0;
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       const char *tz = switch_channel_get_variable(channel, "timezone");
 
        int mod_min;
        char buffer[3];
@@ -322,7 +324,18 @@ static switch_status_t ja_say_time(switch_core_session_t *session, char *tosay,
                target = switch_time_make(t, 0);
        else
                target = switch_micro_time_now();
-       switch_time_exp_lt(&tm, target);
+
+       if (tz) {
+               int check = atoi(tz);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+               if (check) {
+                       switch_time_exp_tz(&tm, target, check);
+               } else {
+                       switch_time_exp_tz_name(tz, &tm, target);
+               }
+       } else {
+               switch_time_exp_lt(&tm, target);
+       }
 
        switch (say_args->type) {
        case SST_CURRENT_DATE_TIME:
index f6dec530d173b12907330b24b8828001736a4c33..6ab2bb98bb2cd40393f5c89787c07d24e34e127c 100644 (file)
@@ -178,6 +178,8 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
        switch_time_t target = 0;
        switch_time_exp_t tm;
        uint8_t say_date = 0, say_time = 0;
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       const char *tz = switch_channel_get_variable(channel, "timezone");
 
        if (say_args->type == SST_TIME_MEASUREMENT) {
                int64_t hours = 0;
@@ -262,7 +264,18 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
        } else {
                target = switch_micro_time_now();
        }
-       switch_time_exp_lt(&tm, target);
+
+       if (tz) {
+               int check = atoi(tz);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+               if (check) {
+                       switch_time_exp_tz(&tm, target, check);
+               } else {
+                       switch_time_exp_tz_name(tz, &tm, target);
+               }
+       } else {
+               switch_time_exp_lt(&tm, target);
+       }
 
        switch (say_args->type) {
        case SST_CURRENT_DATE_TIME:
index ac60b01d9adccf87b04cd41c266bd923c6e9ae96..a78251a0249df634719ae34c81e7e79bf4c35a3a 100644 (file)
@@ -234,6 +234,8 @@ static switch_status_t th_say_time(switch_core_session_t *session, char *tosay,
        int32_t t;
        switch_time_t target = 0;
        switch_time_exp_t tm;
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       const char *tz = switch_channel_get_variable(channel, "timezone");
 #if 0
        switch_time_t this_morning;
        switch_time_exp_t tm2;
@@ -323,7 +325,18 @@ static switch_status_t th_say_time(switch_core_session_t *session, char *tosay,
                target = switch_time_make(t, 0);
        else
                target = switch_micro_time_now();
-       switch_time_exp_lt(&tm, target);
+
+       if (tz) {
+               int check = atoi(tz);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+               if (check) {
+                       switch_time_exp_tz(&tm, target, check);
+               } else {
+                       switch_time_exp_tz_name(tz, &tm, target);
+               }
+       } else {
+               switch_time_exp_lt(&tm, target);
+       }
 
        switch (say_args->type) {
        case SST_CURRENT_DATE_TIME:
index 457654396d997f6c7e7c4c419889dfeda6e2fb8a..f84932dd5c90ccd55afc2b65c57c0185d2c4e8c4 100644 (file)
@@ -198,6 +198,8 @@ static switch_status_t zh_say_time(switch_core_session_t *session, char *tosay,
        int32_t t;
        switch_time_t target = 0;
        switch_time_exp_t tm;
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       const char *tz = switch_channel_get_variable(channel, "timezone");
 #if 0
        switch_time_t this_morning;
        switch_time_exp_t tm2;
@@ -287,7 +289,18 @@ static switch_status_t zh_say_time(switch_core_session_t *session, char *tosay,
                target = switch_time_make(t, 0);
        else
                target = switch_micro_time_now();
-       switch_time_exp_lt(&tm, target);
+
+       if (tz) {
+               int check = atoi(tz);
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
+               if (check) {
+                       switch_time_exp_tz(&tm, target, check);
+               } else {
+                       switch_time_exp_tz_name(tz, &tm, target);
+               }
+       } else {
+               switch_time_exp_lt(&tm, target);
+       }
 
        switch (say_args->type) {
        case SST_CURRENT_DATE_TIME: