将“当前时间”转换为“自00:00以来的分钟数”计算帮助(Convert “current time” to “time in minutes since 00:00” calculation help)
我还没有使用过NSDate,所以我想帮助我做一个计算。
我有一个整数,从午夜开始,我的商店的关闭时间以分钟为单位。 基本上,我的商店在下午5点关门,这给了我整数1020。
所以现在是下午10点45分或22点45分。 从00:00开始的整数是1365,从这我可以说
if (storeHour < currentTime) { // closed! }
但是,我不知道我从NSDate的“22.45”中得到的转换为表示时间为00:00的整数。 NSDate中有什么可以帮助我吗?
谢谢
I haven't used NSDate that much, so I'd like some help with a calculation I am doing.
I have an integer that has my store's closing hour in minutes since midnight. Basically, my store closes at 5.00PM, which gives me the integer 1020.
So right now it's 10.45PM or 22.45. Integer since 00:00 is 1365, and from this I can say
if (storeHour < currentTime) { // closed! }
However, I don't know how I get from "22.45" that I have from NSDate to converting it to an integer representing time since 00:00. Is there something in NSDate that can help me with that?
Thx
原文:https://stackoverflow.com/questions/1817749
最满意答案
您可能希望在遇到错误时重定向您的用户。 通过使用您的代码:
$rootScope.$on("$routeChangeError", function (event, current, previous, rejection){ $location.url('/error'); });
然后在你的$ routeProvider(可能是$ stateProvider,取决于你使用的是什么),做类似以下的事情
$routeProvider .when('/error', { templateUrl: 'error.html', controller: 'YourErrorController' })
You probably want to redirect your user when hitting an error. As by using your code:
$rootScope.$on("$routeChangeError", function (event, current, previous, rejection){ $location.url('/error'); });
And then in your $routeProvider (maybe $stateProvider depending on what you are using), do something like the following
$routeProvider .when('/error', { templateUrl: 'error.html', controller: 'YourErrorController' })
相关问答
更多-
我会利用ng-view ( $viewContentLoaded , $viewContentLoaded ,see here )和$route $routeChangeSuccess ( $routeChangeSuccess ,广播,见这里 )触发的事件。 用户导航部分的控制器必须根据适当事件的到达和模型的状态(可能是currentUser )设置控制UI可见性的标志。 I would make use of the events fired by ng-view ($viewContentLoaded ...
-
请参阅此文档 。 我看不到你的代码,但我猜你的指令模板包含多个根元素。 所以在原则上,而不是做 做 Please, see this documentation. I can't see your code, but I guess your directive template contains more than ...
-
将所有页面滚动到正文顶部而不是我的ng-view(Load all pages scrolled to top of the body instead of my ng-view)[2022-07-19]
您可以使用带有ng-view的autoscroll param来完成这项工作。 You can use the autoscroll param with ng-view to make this work. -
您可能希望在遇到错误时重定向您的用户。 通过使用您的代码: $rootScope.$on("$routeChangeError", function (event, current, previous, rejection){ $location.url('/error'); }); 然后在你的$ routeProvider(可能是$ stateProvider,取决于你使用的是什么),做类似以下的事情 $routeProvider .when('/error', { te ...
-
这篇文章展示了如何在bootstrap之后使用RequireJS加载AngularJS组件。 http://www.bennadel.com/blog/2554-Loading-AngularJS-Components-With-RequireJS-After-Application-Bootstrap.htm 它的演示就在这里 http://bennadel.github.io/JavaScript-Demos/demos/loading-angularjs-with-requirejs-after-bo ...
-
angularJS在ng-view中加载非角度javascript文件(angularJS load non-angular javascript file within ng-view)[2022-03-26]
目前没有方法在子页面中包含javascript文件。 (我认为Josh的解决方案不适用于实际的服务器)。 为什么不使用build in属性,而不是使用自定义指令(可能有效,但很麻烦) 尝试这个: 在主页面中包含自定义javascript文件(来自服务器) 为画布创建另一个html文件,并将#container和#json放在那里 在子页面中,包括画布html< ...您有两个ng-app声明。 您应该删除html元素中的那个。 你还在“home”的配置中写了“template”而不是“templateUrl”。 app.config(function ($routeProvider) { $routeProvider.when('/', { controller: 'HomeController', templateUrl: '/app/partials/home.html' }) ... } 这是一个工作的plu ...除了ng-view页面加载(other than ng-view page loading)[2023-07-08]
ng-include是你的朋友。 看文件 这是一个简单的方法,但你应该去doc,看看有什么额外的选项可以做onload,如果你想自动滚动或做某种动画。你以错误的方式注入$routeProvider : app.config([function ($routeProvider) { /* $routeProvider will be undefined */ ... }]); 事实上,你混合了两种角度注射方式: app.config(function ($routeProvider) { ... }); 和 app.config(['$routeProvider', function ($routeProvider) { ...我不知道这是否是Rube Goldberg的工作,但我通过以下方式解决了我的问题: 在指向远程地址的本地模板上创建动态iframe。 换一种说法: .when('/ WebMail',{controller:HomeCtrl,templateUrl:'\ templates \ webMail.html'}) webMail.html: I do not know if this is a Rube ...相关文章
更多- The Log: What every software engineer should know about real-time data's unifying abstraction
- Real-Time Rendering 笔记 --- 1-4章
- SimpleDateFormat 如何格式化 "Fri, 02-Jan-2020 00:00:00 GMT" 的时间格式
- POJ 3620 Avoid The Lakes【DFS水题练格式Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Total Sub】
- [译文] 恶意软件行为综述 - A View on Current Malware Behaviors
- Python实现用Hadoop的map/reduce对web日志进行统计
- Java日期时间
- VC++的Unicode编程(经典之作,交流传薪)
- VC++的Unicode编程(经典之作,交流传薪)
- VC++的Unicode编程(经典之作,交流传薪)
最新问答
更多- 您如何使用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)