c-在脚本中定义特定日期-unix日期



我在一个名为"Liquidsoap"的音频广播语言脚本中寻找了一种方法来定义一个月中的特定工作日,以操作切换功能。该语言是使用C和oCaml构建的,并最终输出到IceCast。

我只需要有人帮我简化这段代码。我不知道如何将其翻译成我需要的东西。。

use the date
function from unix to build a function which will choose the good day (and
do almost whatever you want in this way). For instance,
# Function returning true if this is a good day and false otherwise
def good_day() =
# Name of the current day
day_name = get_process_output("date +%A")
# Remove trailing n
day_name = string.replace(pattern="n",fun (_) -> "", day_name)
# Number of current week
week = int_of_string(get_process_output("date +%U"))
# Return true on tuesday every four week
(day_name == "Tuesday") and (week mod 1 == 0)
end
out = switch([(good_day, good_day_playlist), ...])

我基本上需要在里面定义一个月的工作日。。。比方说,这个月的第二个星期二。。。

您可以使用C标准库<time.h>中的timemktime来获取一个结构,该结构包含当前工作日(基于0)对应的成员:http://www.cplusplus.com/reference/clibrary/ctime/

最新更新