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

标签 c unix date ocaml

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

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

最佳答案

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

关于c - 在脚本中定义特定日期 - unix date,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13156167/

相关文章:

sql - SQL 查询的日期

c++ - 使用 _CrtDumpMemoryLeaks 将数据显示到控制台

c - 在函数内声明 struct timeval time

c - OpenCV cvLoadImage 不接受 char* 作为文件名,但接受 argv[1]

c - 在 C 中使用 fwrite() 的 fseek() 之后,fread() 不工作

unix - 操纵电子邮件地址的路径

php - 按位置对月份数组进行排序

sorting - 排序并保留具有最高值(value)的唯一副本

c - msgsnd 无权限错误

date - Typescript 认为 getYear 在 Date 类型上不存在