zoukankan      html  css  js  c++  java
  • unix 时间的相关函数

    unix 的时间大致可分为实时的时间和结构体中的时间

    1\计算 1900 到 1970 年之间的秒数 RFC1305 - Network Time Protocol  中规定,网络协议中的,时间戳的格式是一个四个八位组。其值是自 1900 年以来的秒数。 unix 没有提供函数以获得 1900 年以来的秒数,但它提供了 1970 年(UTC 时间)以来的秒数的获取方式。由于  1900 -1970 年之间的天数是一个固定值。所以我们可以得到 1970年以来的秒数。//  闰年 366天,平年 365天,1900 - 1970 年有 18个闰年,static const int seconds =   ( ( 1970-1900 ) *365+18  ) *24*60*60;时间的精度poxis 标准中,可以取到的时间的精度是 微秒(um)。 这是用 gettimeofday() 取得的。需要说明的是,time() 函数取得的系统秒数,未必是一个精确的值。可能和 gettimeofday() 得到的值 落后一秒。因为 time()是一个函数,而不是一个系统调用 。它只取系统中保存的一个数据结构。因此。在高精度的场合,time()取到的秒数需要和 gettimeofday() 取到的秒数做一下比较。如果不一样,则给 time 得到的时间补上一秒。 gettimeofday(& time_t  trecv, tsend;
    // 获取当前的 localtimetime( &tsend );
    //补齐差的秒数tsend += ( ( now.tv_sec &1^ ( tsend &1) );
     一些系统中提供了取得纳秒的函数。另外, odbc 的 TIMESTAMP_STRUCT 数据类型,也是提供到纳秒的精度。


              




    timeval now; 
    now, NULL );


      


  • 相关阅读:
    Solution SQL Server 2008 Configuration Manager Cannot open problem.
    Grant, Revoke, Deny
    Solution: 无法察看SQL Server 数据库属性 错误: "There is no row at position 0. (System.Data)"
    SQL SMO 学习
    恢复误删的桌面 回收站
    SQL Server Security Understanding.
    SQL Server 中的 Schema, User, Login, Role
    形而上学 辩证法
    文档归档的配置发送
    无法从服务器加载工作流操作
  • 原文地址:https://www.cnblogs.com/diylab/p/1415730.html
Copyright © 2011-2022 走看看