VTK
dox/Common/vtkTimePointUtility.h
Go to the documentation of this file.
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 "vtkObject.h"
00034 
00035 class VTK_COMMON_EXPORT vtkTimePointUtility : public vtkObject
00036 {
00037 public:
00038   static vtkTimePointUtility *New();
00039   vtkTypeMacro(vtkTimePointUtility,vtkObject);
00040   void PrintSelf(ostream& os, vtkIndent indent);
00041 
00043 
00044   static vtkTypeUInt64 DateToTimePoint(
00045     int year, int month, int day);
00047 
00049 
00051   static vtkTypeUInt64 TimeToTimePoint(
00052     int hour, int minute, int second, int millis = 0);
00054 
00056 
00057   static vtkTypeUInt64 DateTimeToTimePoint(
00058     int year, int month, int day, 
00059     int hour, int minute, int sec, int millis = 0);
00061 
00063 
00065   static void GetDate(vtkTypeUInt64 time, 
00066     int& year, int& month, int& day);
00068 
00070 
00072   static void GetTime(vtkTypeUInt64 time, 
00073     int& hour, int& minute, int& second, int& millis);
00075 
00077 
00079   static void GetDateTime(vtkTypeUInt64 time, 
00080     int& year, int& month, int& day, 
00081     int& hour, int& minute, int& second, int& millis);
00083 
00085   static int GetYear(vtkTypeUInt64 time);
00086 
00088   static int GetMonth(vtkTypeUInt64 time);
00089 
00091   static int GetDay(vtkTypeUInt64 time);
00092 
00094   static int GetHour(vtkTypeUInt64 time);
00095 
00097   static int GetMinute(vtkTypeUInt64 time);
00098 
00100   static int GetSecond(vtkTypeUInt64 time);
00101 
00103   static int GetMillisecond(vtkTypeUInt64 time);
00104 
00105   //BTX
00106   enum {
00107     ISO8601_DATETIME_MILLIS = 0,
00108     ISO8601_DATETIME = 1,
00109     ISO8601_DATE = 2,
00110     ISO8601_TIME_MILLIS = 3,
00111     ISO8601_TIME = 4
00112     };
00113 
00114   static const int MILLIS_PER_SECOND;
00115   static const int MILLIS_PER_MINUTE;
00116   static const int MILLIS_PER_HOUR;
00117   static const int MILLIS_PER_DAY;
00118   static const int SECONDS_PER_MINUTE;
00119   static const int SECONDS_PER_HOUR;
00120   static const int SECONDS_PER_DAY;
00121   static const int MINUTES_PER_HOUR;
00122   static const int MINUTES_PER_DAY;
00123   static const int HOURS_PER_DAY;
00124 
00126 
00131   static vtkTypeUInt64 ISO8601ToTimePoint(const char* str, bool* ok = NULL);
00132   //ETX
00134 
00136 
00144   static const char* TimePointToISO8601(
00145     vtkTypeUInt64, int format = ISO8601_DATETIME_MILLIS);
00147 
00148 protected:
00149   vtkTimePointUtility() {};
00150   ~vtkTimePointUtility() {};
00151 
00152 private:
00153   vtkTimePointUtility(const vtkTimePointUtility&);  // Not implemented.
00154   void operator=(const vtkTimePointUtility&);  // Not implemented.
00155 };
00156 
00157 #endif