将时间范围描述为String的任何标准格式?想要使用它开放时间 [英] Any standard format to describe time ranges as String? Want to use it for opening hours

查看:188
本文介绍了将时间范围描述为String的任何标准格式?想要使用它开放时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想使用它来打开像...的开放时间。

We want to use it for opening hours like...


  • Mo 11:00-13:00

  • 星期二9:00-18:00

  • 更新 现在需要:Wed 8:00-11:30,Wed 12 :00-17:00

  • Mo 11:00-13:00
  • Tue 9:00-18:00
  • Update Now required: Wed 8:00-11:30, Wed 12:00-17:00

我们有一个基于Ruby的服务器,并向客户端提供JSON和XML。我们遵循ActiveResource模式,以便我们可以使用我们的客户端插件

We have a Ruby based server and deliver JSON and XML to the clients. We follow the ActiveResource pattern, so that we can use plug ins in our clients

这是我们当前的专有方法:

That's our current proprietary approach:

"availabilities":[{"end_time":"00:00","weekdays":"0,1,2,3,4,5,6","start_time":"00:00"}]


推荐答案

cron格式专门为此设计,包括相对日期,如从12月之前的每个月的第一个星期一的午夜到凌晨1点。

cron format was designed specifically for this, including relative dates like "from midnight to 1 AM of the first Monday each month except December".

编辑:所有示例的cron表达式:

Edit: cron expressions for all examples:

* 11-12 * * mon
* 9-17 * * tue
* 8-10 * * wed
0-29 11 * * wed
* 12-16 * * wed

这篇关于将时间范围描述为String的任何标准格式?想要使用它开放时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆