VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkTimePointUtility.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 /*------------------------------------------------------------------------- 00016 Copyright 2008 Sandia Corporation. 00017 Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00018 the U.S. Government retains certain rights in this software. 00019 -------------------------------------------------------------------------*/ 00030 #ifndef __vtkTimePointUtility_h 00031 #define __vtkTimePointUtility_h 00032 00033 #include "vtkCommonCoreModule.h" // For export macro 00034 #include "vtkObject.h" 00035 00036 class VTKCOMMONCORE_EXPORT vtkTimePointUtility : public vtkObject 00037 { 00038 public: 00039 static vtkTimePointUtility *New(); 00040 vtkTypeMacro(vtkTimePointUtility,vtkObject); 00041 void PrintSelf(ostream& os, vtkIndent indent); 00042 00044 00045 static vtkTypeUInt64 DateToTimePoint( 00046 int year, int month, int day); 00048 00050 00052 static vtkTypeUInt64 TimeToTimePoint( 00053 int hour, int minute, int second, int millis = 0); 00055 00057 00058 static vtkTypeUInt64 DateTimeToTimePoint( 00059 int year, int month, int day, 00060 int hour, int minute, int sec, int millis = 0); 00062 00064 00066 static void GetDate(vtkTypeUInt64 time, 00067 int& year, int& month, int& day); 00069 00071 00073 static void GetTime(vtkTypeUInt64 time, 00074 int& hour, int& minute, int& second, int& millis); 00076 00078 00080 static void GetDateTime(vtkTypeUInt64 time, 00081 int& year, int& month, int& day, 00082 int& hour, int& minute, int& second, int& millis); 00084 00086 static int GetYear(vtkTypeUInt64 time); 00087 00089 static int GetMonth(vtkTypeUInt64 time); 00090 00092 static int GetDay(vtkTypeUInt64 time); 00093 00095 static int GetHour(vtkTypeUInt64 time); 00096 00098 static int GetMinute(vtkTypeUInt64 time); 00099 00101 static int GetSecond(vtkTypeUInt64 time); 00102 00104 static int GetMillisecond(vtkTypeUInt64 time); 00105 00106 //BTX 00107 enum { 00108 ISO8601_DATETIME_MILLIS = 0, 00109 ISO8601_DATETIME = 1, 00110 ISO8601_DATE = 2, 00111 ISO8601_TIME_MILLIS = 3, 00112 ISO8601_TIME = 4 00113 }; 00114 00115 static const int MILLIS_PER_SECOND; 00116 static const int MILLIS_PER_MINUTE; 00117 static const int MILLIS_PER_HOUR; 00118 static const int MILLIS_PER_DAY; 00119 static const int SECONDS_PER_MINUTE; 00120 static const int SECONDS_PER_HOUR; 00121 static const int SECONDS_PER_DAY; 00122 static const int MINUTES_PER_HOUR; 00123 static const int MINUTES_PER_DAY; 00124 static const int HOURS_PER_DAY; 00125 00127 00132 static vtkTypeUInt64 ISO8601ToTimePoint(const char* str, bool* ok = NULL); 00133 //ETX 00135 00137 00145 static const char* TimePointToISO8601( 00146 vtkTypeUInt64, int format = ISO8601_DATETIME_MILLIS); 00148 00149 protected: 00150 vtkTimePointUtility() {}; 00151 ~vtkTimePointUtility() {}; 00152 00153 private: 00154 vtkTimePointUtility(const vtkTimePointUtility&); // Not implemented. 00155 void operator=(const vtkTimePointUtility&); // Not implemented. 00156 }; 00157 00158 #endif