本文介绍了如何使用日期时间计算夜间时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hey Codeproject,
我已经知道一天有86400秒,我想让86400的颜色更黑一些标记。
所以,我开始做以下事情:
Hey Codeproject,
I've already figured out that there's 86400 seconds in a day, and I'd like to make a color more black towards the 86400 mark.
So, I started by doing the following:
// pseudo code
// Color * 0f = Completely Transparent
// BackgroundColor = Color
Color.Black * (1f / 86400f * DateTime.TotalSeconds)
问题是,当它到达午夜时,总秒数将重置为0,因为新的一天开始了。那时候还是晚上想的。
有没有人知道如何解决这个问题?
最好的问候,
- 11841791
我的尝试:
The problem is though, the moment it hits midnight, the total seconds will be reset to 0, since a new day started. It's still night thought at that point.
Does anyone have an idea on how to fix this?
Best Regards,
- 11841791
What I have tried:
// pseudo code
// Color * 0f = Completely Transparent
// BackgroundColor = Color
Color.Black * (1f / 86400f * DateTime.TotalSeconds)
推荐答案
abs((86400/2)-DateTime.TotalSeconds)
[更新]
注意我的公式的最大结果是 43200 。
这篇关于如何使用日期时间计算夜间时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!