VTK
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 -------------------------------------------------------------------------*/
31 #ifndef vtkTimePointUtility_h
32 #define vtkTimePointUtility_h
33 
34 #include "vtkCommonCoreModule.h" // For export macro
35 #include "vtkObject.h"
36 
37 class VTKCOMMONCORE_EXPORT vtkTimePointUtility : public vtkObject
38 {
39 public:
42  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
43 
47  static vtkTypeUInt64 DateToTimePoint(
48  int year, int month, int day);
49 
54  static vtkTypeUInt64 TimeToTimePoint(
55  int hour, int minute, int second, int millis = 0);
56 
60  static vtkTypeUInt64 DateTimeToTimePoint(
61  int year, int month, int day,
62  int hour, int minute, int sec, int millis = 0);
63 
68  static void GetDate(vtkTypeUInt64 time,
69  int& year, int& month, int& day);
70 
75  static void GetTime(vtkTypeUInt64 time,
76  int& hour, int& minute, int& second, int& millis);
77 
82  static void GetDateTime(vtkTypeUInt64 time,
83  int& year, int& month, int& day,
84  int& hour, int& minute, int& second, int& millis);
85 
89  static int GetYear(vtkTypeUInt64 time);
90 
94  static int GetMonth(vtkTypeUInt64 time);
95 
99  static int GetDay(vtkTypeUInt64 time);
100 
104  static int GetHour(vtkTypeUInt64 time);
105 
109  static int GetMinute(vtkTypeUInt64 time);
110 
114  static int GetSecond(vtkTypeUInt64 time);
115 
119  static int GetMillisecond(vtkTypeUInt64 time);
120 
121  enum {
122  ISO8601_DATETIME_MILLIS = 0,
123  ISO8601_DATETIME = 1,
124  ISO8601_DATE = 2,
125  ISO8601_TIME_MILLIS = 3,
126  ISO8601_TIME = 4
127  };
128 
129  static const int MILLIS_PER_SECOND;
130  static const int MILLIS_PER_MINUTE;
131  static const int MILLIS_PER_HOUR;
132  static const int MILLIS_PER_DAY;
133  static const int SECONDS_PER_MINUTE;
134  static const int SECONDS_PER_HOUR;
135  static const int SECONDS_PER_DAY;
136  static const int MINUTES_PER_HOUR;
137  static const int MINUTES_PER_DAY;
138  static const int HOURS_PER_DAY;
139 
147  static vtkTypeUInt64 ISO8601ToTimePoint(const char* str, bool* ok = NULL);
148 
167  static const char* TimePointToISO8601(
168  vtkTypeUInt64, int format = ISO8601_DATETIME_MILLIS);
169 
170 protected:
172  ~vtkTimePointUtility() VTK_OVERRIDE {}
173 
174 private:
175  vtkTimePointUtility(const vtkTimePointUtility&) VTK_DELETE_FUNCTION;
176  void operator=(const vtkTimePointUtility&) VTK_DELETE_FUNCTION;
177 };
178 
179 #endif
vtkTimePointUtility::GetDate
static void GetDate(vtkTypeUInt64 time, int &year, int &month, int &day)
Retrieve the year, month, and day of a time point.
vtkTimePointUtility::SECONDS_PER_MINUTE
static const int SECONDS_PER_MINUTE
Definition: vtkTimePointUtility.h:133
vtkTimePointUtility::GetMillisecond
static int GetMillisecond(vtkTypeUInt64 time)
Retrieve the milliseconds from the start of the last second.
vtkTimePointUtility::DateTimeToTimePoint
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.
vtkTimePointUtility::MILLIS_PER_SECOND
static const int MILLIS_PER_SECOND
Definition: vtkTimePointUtility.h:129
vtkTimePointUtility::GetDateTime
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.
vtkTimePointUtility::MILLIS_PER_MINUTE
static const int MILLIS_PER_MINUTE
Definition: vtkTimePointUtility.h:130
vtkTimePointUtility::MILLIS_PER_DAY
static const int MILLIS_PER_DAY
Definition: vtkTimePointUtility.h:132
vtkTimePointUtility::GetSecond
static int GetSecond(vtkTypeUInt64 time)
Retrieve the number of seconds from the start of the last minute.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkTimePointUtility::New
static vtkTimePointUtility * New()
vtkX3D::time
@ time
Definition: vtkX3D.h:497
vtkTimePointUtility::MINUTES_PER_DAY
static const int MINUTES_PER_DAY
Definition: vtkTimePointUtility.h:137
vtkTimePointUtility::GetDay
static int GetDay(vtkTypeUInt64 time)
Retrieve the day of the month from a time point.
vtkTimePointUtility::~vtkTimePointUtility
~vtkTimePointUtility() override
Definition: vtkTimePointUtility.h:172
vtkTimePointUtility::GetMinute
static int GetMinute(vtkTypeUInt64 time)
Retrieve the number of minutes from the start of the last hour.
vtkTimePointUtility::ISO8601ToTimePoint
static vtkTypeUInt64 ISO8601ToTimePoint(const char *str, bool *ok=NULL)
Converts a ISO8601 string into a VTK timepoint.
vtkTimePointUtility::vtkTimePointUtility
vtkTimePointUtility()
Definition: vtkTimePointUtility.h:171
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkTimePointUtility::GetHour
static int GetHour(vtkTypeUInt64 time)
Retrieve the hour of the day from the time point.
vtkTimePointUtility::HOURS_PER_DAY
static const int HOURS_PER_DAY
Definition: vtkTimePointUtility.h:138
vtkObject.h
vtkTimePointUtility::MILLIS_PER_HOUR
static const int MILLIS_PER_HOUR
Definition: vtkTimePointUtility.h:131
vtkTimePointUtility::TimeToTimePoint
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.
vtkTimePointUtility::TimePointToISO8601
static const char * TimePointToISO8601(vtkTypeUInt64, int format=ISO8601_DATETIME_MILLIS)
Converts a VTK timepoint into one of the following ISO8601 formats.
vtkTimePointUtility::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTimePointUtility::GetMonth
static int GetMonth(vtkTypeUInt64 time)
Retrieve the month from a time point.
vtkTimePointUtility::SECONDS_PER_DAY
static const int SECONDS_PER_DAY
Definition: vtkTimePointUtility.h:135
vtkTimePointUtility::DateToTimePoint
static vtkTypeUInt64 DateToTimePoint(int year, int month, int day)
Return the time point for 12:00am on a specified day.
vtkTimePointUtility::SECONDS_PER_HOUR
static const int SECONDS_PER_HOUR
Definition: vtkTimePointUtility.h:134
vtkTimePointUtility::GetTime
static void GetTime(vtkTypeUInt64 time, int &hour, int &minute, int &second, int &millis)
Retrieve the hour, minute, second, and milliseconds of a time point.
vtkTimePointUtility::MINUTES_PER_HOUR
static const int MINUTES_PER_HOUR
Definition: vtkTimePointUtility.h:136
vtkTimePointUtility
performs common time operations
Definition: vtkTimePointUtility.h:38
vtkTimePointUtility::GetYear
static int GetYear(vtkTypeUInt64 time)
Retrieve the year from a time point.