VTK  9.0.3
vtkTimePointUtility.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkTimePointUtility.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16  Copyright 2008 Sandia Corporation.
17  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
18  the U.S. Government retains certain rights in this software.
19 -------------------------------------------------------------------------*/
28 #ifndef vtkTimePointUtility_h
29 #define vtkTimePointUtility_h
30 
31 #include "vtkCommonCoreModule.h" // For export macro
32 #include "vtkObject.h"
33 
34 class VTKCOMMONCORE_EXPORT vtkTimePointUtility : public vtkObject
35 {
36 public:
39  void PrintSelf(ostream& os, vtkIndent indent) override;
40 
44  static vtkTypeUInt64 DateToTimePoint(int year, int month, int day);
45 
50  static vtkTypeUInt64 TimeToTimePoint(int hour, int minute, int second, int millis = 0);
51 
55  static vtkTypeUInt64 DateTimeToTimePoint(
56  int year, int month, int day, int hour, int minute, int sec, int millis = 0);
57 
62  static void GetDate(vtkTypeUInt64 time, int& year, int& month, int& day);
63 
68  static void GetTime(vtkTypeUInt64 time, int& hour, int& minute, int& second, int& millis);
69 
74  static void GetDateTime(vtkTypeUInt64 time, int& year, int& month, int& day, int& hour,
75  int& minute, int& second, int& millis);
76 
80  static int GetYear(vtkTypeUInt64 time);
81 
85  static int GetMonth(vtkTypeUInt64 time);
86 
90  static int GetDay(vtkTypeUInt64 time);
91 
95  static int GetHour(vtkTypeUInt64 time);
96 
100  static int GetMinute(vtkTypeUInt64 time);
101 
105  static int GetSecond(vtkTypeUInt64 time);
106 
110  static int GetMillisecond(vtkTypeUInt64 time);
111 
112  enum
113  {
114  ISO8601_DATETIME_MILLIS = 0,
115  ISO8601_DATETIME = 1,
116  ISO8601_DATE = 2,
117  ISO8601_TIME_MILLIS = 3,
118  ISO8601_TIME = 4
119  };
120 
121  static const int MILLIS_PER_SECOND;
122  static const int MILLIS_PER_MINUTE;
123  static const int MILLIS_PER_HOUR;
124  static const int MILLIS_PER_DAY;
125  static const int SECONDS_PER_MINUTE;
126  static const int SECONDS_PER_HOUR;
127  static const int SECONDS_PER_DAY;
128  static const int MINUTES_PER_HOUR;
129  static const int MINUTES_PER_DAY;
130  static const int HOURS_PER_DAY;
131 
139  static vtkTypeUInt64 ISO8601ToTimePoint(const char* str, bool* ok = nullptr);
140 
159  static const char* TimePointToISO8601(vtkTypeUInt64, int format = ISO8601_DATETIME_MILLIS);
160 
161 protected:
163  ~vtkTimePointUtility() override {}
164 
165 private:
166  vtkTimePointUtility(const vtkTimePointUtility&) = delete;
167  void operator=(const vtkTimePointUtility&) = delete;
168 };
169 
170 #endif
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
performs common time operations
static int GetMillisecond(vtkTypeUInt64 time)
Retrieve the milliseconds from the start of the last second.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkTypeUInt64 DateToTimePoint(int year, int month, int day)
Return the time point for 12:00am on a specified day.
static const int SECONDS_PER_DAY
static int GetDay(vtkTypeUInt64 time)
Retrieve the day of the month from a time point.
static const int MILLIS_PER_HOUR
static vtkTypeUInt64 TimeToTimePoint(int hour, int minute, int second, int millis=0)
Return the time point for a time of day (the number of milliseconds from 12:00am.
static const int HOURS_PER_DAY
static int GetYear(vtkTypeUInt64 time)
Retrieve the year from a time point.
static void GetDate(vtkTypeUInt64 time, int &year, int &month, int &day)
Retrieve the year, month, and day of a time point.
static const int MILLIS_PER_MINUTE
static int GetHour(vtkTypeUInt64 time)
Retrieve the hour of the day from the time point.
static const char * TimePointToISO8601(vtkTypeUInt64, int format=ISO8601_DATETIME_MILLIS)
Converts a VTK timepoint into one of the following ISO8601 formats.
static void GetTime(vtkTypeUInt64 time, int &hour, int &minute, int &second, int &millis)
Retrieve the hour, minute, second, and milliseconds of a time point.
static vtkTypeUInt64 ISO8601ToTimePoint(const char *str, bool *ok=nullptr)
Converts a ISO8601 string into a VTK timepoint.
static void GetDateTime(vtkTypeUInt64 time, int &year, int &month, int &day, int &hour, int &minute, int &second, int &millis)
Retrieve the date and time of a time point.
static int GetMinute(vtkTypeUInt64 time)
Retrieve the number of minutes from the start of the last hour.
static int GetMonth(vtkTypeUInt64 time)
Retrieve the month from a time point.
static vtkTimePointUtility * New()
static const int MILLIS_PER_DAY
static const int SECONDS_PER_MINUTE
static const int MINUTES_PER_DAY
static const int MILLIS_PER_SECOND
static const int SECONDS_PER_HOUR
static vtkTypeUInt64 DateTimeToTimePoint(int year, int month, int day, int hour, int minute, int sec, int millis=0)
Return the time point for a date and time.
static int GetSecond(vtkTypeUInt64 time)
Retrieve the number of seconds from the start of the last minute.
static const int MINUTES_PER_HOUR
@ time
Definition: vtkX3D.h:503