boost 时间

ch2
timer
只有如下三个成员函数,单位是秒

#include <boost/timer.hpp>
#include <iostream>
using namespace boost;
using namespace std;

int main()
{
    timer t;
    cout << "MAX TIME VALUE " << t.elapsed_max()/3600 << "h" << endl;
    cout << "min TIME VALUE " << t.elapsed_min() << "s" << endl;

    cout << "now time elaped" << t.elapsed() << "s" << endl;

}
max timespan second 2.14748e+06
min_timespan second 0.001
now time elapsed 0.067s

progress_timer, timer的另一层包装,析构函数时会自动输出progress_timer.elapsed()

#include <boost/progress.hpp>
#include <iostream>

using namespace boost;


int main()
{
    boost::progress_timer t;
    std::cout << t.elapsed() << std::endl;

}
#include <boost/progress.hpp>
#include <iostream>

using namespace boost;


int main()
{
    {
    boost::progress_timer t;
    std::cout << t.elapsed() << std::endl;
    }

    {
    boost::progress_timer t;


    }
}
#include <boost/progress.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace boost;
using namespace std;

int main()
{
    vector<string> v(100);
    ofstream fs("./test.txt");

    progress_display pd(v.size());
    for(auto &x : v)
        {
            fs << x << std::endl;
            ++pd;
        }
}
#include <boost/timer.hpp>  
#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>   

using namespace std;
using namespace boost::gregorian;


int main()
{
    date d(2018, 7, 5);
    cout << d.year() << endl;
    cout << d.month() << endl;
    cout << d.day() << endl;
    cout << d.day_of_week() << endl;
    cout << d.day_of_year() << endl;
    cout << d.day_count() << endl;
    cout << d.day_number() << endl;
    cout << d.end_of_month() << endl;
    cout << d.is_infinity() << endl;
    cout << d.week_number() << endl;
    cout << d.year_month_day().year << " " << d.year_month_day().month << endl;



    system("pause");
    return 0;
}
2018
Jul
5
Thu
186
2458305
2458305
2018-Jul-31
0
27
2018 Jul
#include <boost/date_time/gregorian/gregorian.hpp>     
#include <iostream>   
#include <time.h>
using namespace std;
int main()
{
    using namespace boost::gregorian;
    date d1;
    date d2(2017,1,18);
    date d3(2018, Jan, 1);
    //date d4(6666,sabi,50) 不可行
    cout << d1 << endl;
    cout << d2 << endl;
    cout << d3 << endl;

    date d4(d2);

    assert(d1 == date(not_a_date_time));
    assert(d2 == d4);
    assert(d3 > d4);

    date dd1 = from_string("2018.3.1");
    date dd2 = from_string("2018/3/1");
    date dd3 = from_undelimited_string("20180118");

    //天级别的时钟
    cout << day_clock::local_day() << endl;
    cout << day_clock::universal_day() << endl;

    //特殊时间概念枚举变量special_value
    date ds1(neg_infin);
    date ds2(pos_infin);
    date ds3(not_a_date_time);
    date ds4(max_date_time);
    date ds5(min_date_time);

    cout << ds1 << endl;

    //访问date类的日期

    cout << d2.year() << d2.month() << d2.day() << endl;
    cout << d2.day_count() << d2.day_number() << endl;

    date::ymd_type ymd = d2.year_month_day();
    cout << ymd.day << ymd.month << ymd.year << endl;   

    cout << d2.day_of_week() << endl;
    cout << d2.day_of_year() << endl;
    cout << d2.end_of_month() << endl;


    // 转化成字符串输出
    cout << to_simple_string(d2) << endl;
    cout << to_iso_string(d2) << endl;


    //c tm结构体与date 转换
    tm t = to_tm(d2);
    assert(t.tm_hour == 0);
    assert(t.tm_min == 0);

    //assert(t.tm_year == 2018);
    cout << "tm since 1990" << t.tm_year << endl;
    cout << "tm sin Jan 0-11" << t.tm_mon << endl;
    cout << "tm 1-31" << t.tm_mday << endl;

    //日期长度,基本类date_duration,其有方法days()返回时间单位(以天为单位),类型别名为days,派生出 weeks months years
    days da1(10), da2(-100), da3(255);
    assert(da1 > da2 && da1 < da3);
    assert(da1 + da2 == days(-90));

    weeks w(3);

    assert(w.days() == 211);
    months m(5);
    years y(2);
    months m2 = m + y;
    assert(m2.number_of_months() == 29);
    assert((y * 2).number_of_years() == 4);

    return 0;
}

运行结果

C:\Users\咖啡>"C:\Users\咖啡\Documents\Visual Studio 2015\Projects\helloboost\Debug\helloboost.exe"
not-a-date-time
2017-Jan-18
2018-Jan-01
2018-Jan-18
2018-Jan-18
-infinity
2017Jan18
24577722457772
18Jan2017
Wed
18
2017-Jan-31
2017-Jan-18
20170118
tm117
tm0
tm18
    cout << day_clock::local_day() << endl;
    cout << day_clock::universal_day() << endl;

2018-Jul-05

#include <boost/timer.hpp>  
#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>   

using namespace std;
using namespace boost::gregorian;


int main()
{
    date d(2018, 7, 5);
    date dd = from_string("2018.7.6");

     //typedef date_duration days
    days da(10);
    days db(12);
    cout << da + db << endl;
    cout << da.days() << endl;
    assert(da.days() !=  db.days());

    weeks w(3);
    cout << w.days() << endl;
    assert(w.days() == 21);
    cout << w.unit() << endl;

    months m(1);
    cout << m.number_of_months() << endl;
    m += years(1);
    cout <<  m.number_of_months()  << endl;

    system("pause");
    return 0;
}
22
10
21
1
1
13
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园建设方案旨在通过融合先进技术,如物联网、大数据、人工智能等,实现校园的智能化管理与服务。政策的推动和技术的成熟为智慧校园的发展提供了基础。该方案强调了数据的重要性,提出通过数据的整合、开放和共享,构建产学研资用联动的服务体系,以促进校园的精细化治理。 智慧校园的核心建设任务包括数据标准体系和应用标准体系的建设,以及信息化安全与等级保护的实施。方案提出了一站式服务大厅和移动校园的概念,通过整合校内外资源,实现资源共享平台和产教融合就业平台的建设。此外,校园大脑的构建是实现智慧校园的关键,它涉及到数据中心化、数据资产化和数据业务化,以数据驱动业务自动化和智能化。 技术应用方面,方案提出了物联网平台、5G网络、人工智能平台等新技术的融合应用,以打造多场景融合的智慧校园大脑。这包括智慧教室、智慧实验室、智慧图书馆、智慧党建等多领域的智能化应用,旨在提升教学、科研、管理和服务的效率和质量。 在实施层面,智慧校园建设需要统筹规划和分步实施,确保项目的可行性和有效性。方案提出了主题梳理、场景梳理和数据梳理的方法,以及现有技术支持和项目分级的考虑,以指导智慧校园的建设。 最后,智慧校园建设的成功依赖于开放、协同和融合的组织建设。通过战略咨询、分步实施、生态建设和短板补充,可以构建符合学校特色的生态链,实现智慧校园的长远发展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值