- Julia 1.0 Programming Complete Reference Guide
- Ivo Balbaert Adrian Salceanu
- 190字
- 2021-06-24 14:21:43
Dates and times
To get the basic time information, you can use the time() function that returns, for example, 1.408719961424e9, which is the number of seconds since a predefined date called the epoch (normally, the 1st of January 1970 on a Unix system). This is useful for measuring the time interval between two events, for example, to benchmark how long a long calculation takes:
start_time = time() # long computation time_elapsed = time() - start_time println("Time elapsed: $time_elapsed")
Use the Dates module that is built in into the standard library, with Date for days and DateTime for times down to milliseconds, to implement this. Additional time zone functionality can be added through the Timezones.jl package.
The Date and DateTime functions can be constructed as follows, or with simpler versions with less information:
- d = Date(2014,9,1) returns 2014-09-01
- dt = DateTime(2014,9,1,12,30,59,1) returns 2014-09-01T12:30:59.001
These objects can be compared and subtracted to get the duration. The Date function parts or fields can be retrieved through accessor functions, such as year(d), month(d), week(d), and day(d). Other useful functions exist, such as dayofweek, dayname, daysinmonth, dayofyear, isleapyear, and so on.
- JBoss Weld CDI for Java Platform
- Node.js 10實戰
- GraphQL學習指南
- Mastering Adobe Captivate 2017(Fourth Edition)
- Learning Chef
- Python自動化運維快速入門
- PHP+MySQL網站開發技術項目式教程(第2版)
- R語言編程指南
- C#程序設計
- Odoo 10 Implementation Cookbook
- 汽車人機交互界面整合設計
- Python GUI Programming Cookbook(Second Edition)
- Flink入門與實戰
- Software Architecture with Python
- 循序漸進Vue.js 3前端開發實戰