拆分momentJs对象,其中包含小时x - >小时y,值为15min对象(Splitting momentJs object which contains hour x -> hour y, value to 15min objects)
我用的是
moment().add
错误? 因为,使用我的代码,dayTime2
分钟值不会越来越大。目标是将
dayTime2
添加15分钟,只要它超过白天的值即可。示例值:(显然我不是使用这些值irl,而是使用momentJS对象)
startAt
= 7 - > 7.15 - > 7.30等endAt
= 10var dayTime = moment.utc(endAt).format("HH:mm"); var dayTime2 = moment.utc(startAt).format("HH:mm"); while (dayTime2 <= dayTime) { var data = { title: 'VAPAA AIKA', type: 0, startsAt: dayTime2, endsAt: moment(dayTime2).add(30, 'minute') }; moment(dayTime2).add(15, 'minute'); console.log('TIME: ' + dayTime2); console.log(data); }
Am I using
moment().add
wrong? Because, using my code,dayTime2
minutes value is not getting bigger.Goal is to add 15 minutes to
dayTime2
as long as it passes daytime's value.Example values: (obviously I'm not using these value irl, but momentJS objects)
startAt
= 7 -> 7.15 -> 7.30 etc.endAt
= 10var dayTime = moment.utc(endAt).format("HH:mm"); var dayTime2 = moment.utc(startAt).format("HH:mm"); while (dayTime2 <= dayTime) { var data = { title: 'VAPAA AIKA', type: 0, startsAt: dayTime2, endsAt: moment(dayTime2).add(30, 'minute') }; moment(dayTime2).add(15, 'minute'); console.log('TIME: ' + dayTime2); console.log(data); }
原文:https://stackoverflow.com/questions/42117832
最满意答案
我认为你会像对待HTTP URL那样做吗? 您可以使用响应作为字典来设置标头,就像使用
Location
标头一样。 在这种情况下,添加如下行:response['Vary'] = '*'
。为方便起见,您可以使用
add_never_cache_headers()
添加Cache-Control
和Expires
标头。这是一个例子:
from django.utils.cache import add_never_cache_headers class UserPhoneNumberView(FormView): form_class = UserPhoneNumberForm template_name = "get_user_phonenumber.html" def form_valid(self, form): phonenumber = self.request.POST.get("mobile_number") unique = self.request.POST.get("unique") url = "http://example.com/"+unique response = HttpResponse("", status=302) body = "See this url: "+url nonhttp_url = "sms:"+phonenumber+"?body="+body response['Location'] = nonhttp_url # This will add the proper Cache-Control and Expires add_never_cache_headers(response) # Now just add the 'Vary' header response['Vary'] = '*' return response
I'd think that you'd do it just as you would for an HTTP URL? You'd set the headers by using the response as a dictionary, just like you are for the
Location
header. In this case, adding lines like:response['Vary'] = '*'
.As a convenience, you could use
add_never_cache_headers()
to add theCache-Control
andExpires
headers.Here's an example:
from django.utils.cache import add_never_cache_headers class UserPhoneNumberView(FormView): form_class = UserPhoneNumberForm template_name = "get_user_phonenumber.html" def form_valid(self, form): phonenumber = self.request.POST.get("mobile_number") unique = self.request.POST.get("unique") url = "http://example.com/"+unique response = HttpResponse("", status=302) body = "See this url: "+url nonhttp_url = "sms:"+phonenumber+"?body="+body response['Location'] = nonhttp_url # This will add the proper Cache-Control and Expires add_never_cache_headers(response) # Now just add the 'Vary' header response['Vary'] = '*' return response
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
除非您的内容受HTTP身份验证或SSL保护,否则不需要设置Cache-Control: public 。 尝试设置Cache-Control: max-age=nn (其中nn是您希望缓存考虑新鲜响应的整数秒)。 AppEngine 应该删除无缓存。 It isn't necessary to set Cache-Control: public unless your content is protected by HTTP authentication or SSL. Try setting Cache- ...
-
您正在从django(通过django-pipeline)但从Web服务器提供静态文件。 然后.htaccess指令没有效果。 You are serving static files from django (through django-pipeline) but from web server. Then .htaccess directives have no effect.
-
我写的这堂课可以帮到你 function HeaderProc($response,$Run="",$String=1/*[Is 1 IF Use for String Mode ]*/){ print_r($response); if($String==1){ $response=explode("\r\n",$response); } $PartHeader=0; $out ...
-
首先,我认为你在models.py上错过了一个forwardshals: info_image = models.ImageField(upload_to='images/%Y%m/%d') 除非是你的意图,否则我认为它应该是这样的: info_image = models.ImageField(upload_to='images/%Y/%m/%d') ^ 接下来就是你没有在index.html模板的< ...
-
商定的解决方案如下: 1)将需要strip-headers功能的页面集移动到根应用程序下的各自单独的文件夹中 2)使用system.webServer下的以下设置在此文件夹中放置web.config:缺少缓存控制头并不意味着资源无法缓存 - 由客户端(即Web浏览器)决定如何处理此未定义状态。 缓存它(无论是在内存中还是在磁盘中)并且仅在ETag验证时使用该缓存版本对我来说似乎是一个非常合理的实现。 如果您不希望缓存资源,那么您应该使用“max-age = 0,no-store,no-cache,must-revalidate”的缓存控制标头明确说明这一点。 The absence of a cache-control header does not mean a resource cannot be ...我认为你会像对待HTTP URL那样做吗? 您可以使用响应作为字典来设置标头,就像使用Location标头一样。 在这种情况下,添加如下行: response['Vary'] = '*' 。 为方便起见,您可以使用add_never_cache_headers()添加Cache-Control和Expires标头。 这是一个例子: from django.utils.cache import add_never_cache_headers class UserPhoneNumberView(FormVie ...
如何在AngularJS中向$ resource添加Cache-control标头(How to add Cache-control header to $resource in AngularJS)[2022-05-24]
我已将缓存控件放在我的配置中。 $httpProvider.defaults.headers.common['Cache-Control'] = 'no-cache, no-store, must-revalidate'; $httpProvider.defaults.headers.common['Pragma'] = 'no-cache'; $httpProvider.defaults.headers.common['Expires'] = '0'; 有了这个,我能够缓存IE,但我在配置路由器 ...如何在HTTP响应头中发送Cache-Control:no-cache?(How to send Cache-Control: no-cache in HTTP Response header?)[2023-05-18]
尝试这个: Response.AppendHeader("Cache-Control", "no-cache"); 但是,您应该知道单独使用此标头不会为您提供可靠的跨浏览器方式来阻止缓存。 请参阅此答案以获得更准确的解决方案: 确保所有浏览器都不会缓存网页 Try this: Response.AppendHeader("Cache-Control", "no-cache"); However, you should know that this header alone won't give you ...相关文章
更多- Object Oriented Programming
- Guava Objects类详解
- Guava学习笔记:复写的Object常用方法
- 《X战警3:最后之战》(X-Men The Last Stand)[TC]
- elasticsearch-2.x下载与安装
- 基于Lucene 4.x的ik-analyzer
- 最新hadoop2.x视频教程下载
- RabbitMQ 环境配置-基于windows 10 x64
- 传智播客Struts1.x视频教程
- 在Tomcat下配置Solr 4.x 版本
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)