惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Affairs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
P
Palo Alto Networks Blog
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Blog — PlanetScale
Blog — PlanetScale
S
Schneier on Security
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
雷峰网
雷峰网
T
Tenable Blog
人人都是产品经理
人人都是产品经理
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
AWS News Blog
AWS News Blog
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
Scott Helme
Scott Helme
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Recorded Future
Recorded Future
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
Help Net Security
Help Net Security
Cloudbric
Cloudbric
C
Check Point Blog
Engineering at Meta
Engineering at Meta
TaoSecurity Blog
TaoSecurity Blog
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
N
News and Events Feed by Topic
云风的 BLOG
云风的 BLOG
MyScale Blog
MyScale Blog
腾讯CDC
量子位
Application and Cybersecurity Blog
Application and Cybersecurity Blog
K
Kaspersky official blog
Vercel News
Vercel News
F
Full Disclosure
T
Troy Hunt's Blog
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs

博客园 - BackSword

unity ui canvas shader texcoord.zw is not used for ui particle 问题记录,unity shaderlab 模版写入问题 textmeshpro 放大缩小出现黑色边框问题,修改shader FXAA 在桌面平台更高效的原因,MSAA在手机端更高效 glados优惠码 C# Array.Fill 值类型优化。 git 设置github代理 unity physics bug win10 ctrl+space 快捷键冲突问题 msvc C++编译链接 切线空间 c++局部静态变量是线程安全的 c++函数参数和返回值 c++返回值不能是右值对象 状态同步 关于socket通信中大小端转换问题 wpf clickonece 坑 [修复] 启动期间超频失败的错误信息 template return value error C2440: “初始化”: 无法从“const T”转换为“const Player *&”
分享mkgmttime自实现功能。
BackSword · 2022-09-21 · via 博客园 - BackSword
 1 /***
 2  * @Author       : yangzijian
 3  * @Description  : main
 4  * @Date         : 2021-01-25 15:21:31
 5  */
 6 
 7 #include <stdio.h>
 8 #include <iostream>
 9 #include <stdlib.h>
10 #include "UTCTime.h"
11 
12 using namespace std;
13 namespace
14 {
15     const int SecondsPerMinute = 60;
16     const int SecondsPerHour = 3600;
17     const int SecondsPerDay = 86400;
18     const int DaysOfMonth[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
19     int timeZone = 8;
20     bool IsLeapYear(short year)
21     {
22         if (year % 4 != 0)
23             return false;
24         if (year % 100 != 0)
25             return true;
26         return (year % 400) == 0;
27     }
28 
29     time_t mkgmtime(tm* const _Tm)
30     {
31         time_t secs = 0;
32         int realYear = _Tm->tm_year + 1900;
33         int passYear = realYear - 1970;
34         int fhLeapYear = (realYear / 400 - 4);
35         int fLeapYear = realYear / 4 - 1970 / 4;
36         int hLeapYear = realYear / 100 - 1970 / 100;
37         int LeapYear = fLeapYear + fhLeapYear - hLeapYear;
38         int normalYear = passYear - LeapYear;
39         secs += LeapYear * 366 * SecondsPerDay + normalYear * 365 * SecondsPerDay;
40         secs += DaysOfMonth[_Tm->tm_mon] * SecondsPerDay;
41         if (IsLeapYear(realYear))
42         {
43             secs += SecondsPerDay;
44         }
45         secs += (_Tm->tm_mday - 1) * SecondsPerDay;
46         secs += _Tm->tm_hour * SecondsPerHour;
47         secs += _Tm->tm_min * SecondsPerMinute;
48         secs += _Tm->tm_sec;
49         return secs;
50     }
51 
52     time_t GetUtcStamp()
53     {
54         return time(0);
55     }
56 
57     time_t UtcStampToLocalStamp(time_t t)
58     {
59         return t + ((time_t)timeZone) * 3600;
60     }
61 
62     time_t GetLocalStamp()
63     {
64         return UtcStampToLocalStamp(GetUtcStamp());
65     }
66 
67     tm* GetLocalTime()
68     {
69         time_t utcTime = GetLocalStamp();
70         return gmtime(&utcTime);
71     }
72 }
73 
74 int main()
75 {
76     tm* _Tm = GetLocalTime();
77     time_t targetTime = _mkgmtime(_Tm); // 转换成 gmt 时间 mktime 会根据系统时区做转换
78     time_t targetTime2 = mkgmtime(_Tm); // 转换成 gmt 时间 mktime 会根据系统时区做转换
79 
80 
81     system("pause");
82     return 0;
83 }

懒得写注释了,大家随便看看吧...