-2

我寻找一种方法来定义一个月中的特定工作日,以在名为“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), ...])

我基本上需要在那里定义每月的工作日......可以说,每月的第二个星期二......

4

1 回答 1

1

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

于 2012-10-31T11:07:31.410 回答