ARTSAT API  2.7.1
 全て クラス ファイル 関数 変数 型定義 列挙型 列挙型の値 マクロ定義 ページ
ofxSATTime.h
説明を見る。
1 /*
2 ** ARTSAT Project
3 **
4 ** Original Copyright (C) 2011 - 2012 HORIGUCHI Junshi.
5 ** http://iridium.jp/
6 ** zap00365@nifty.com
7 ** Portions Copyright (C) <year> <author>
8 ** <website>
9 ** <e-mail>
10 ** Version openFrameworks
11 ** Website http://artsat.jp/
12 ** E-mail info@artsat.jp
13 **
14 ** This source code is for Xcode.
15 ** Xcode 4.2 (LLVM compiler 3.0)
16 **
17 ** ofxSATTime.h
18 **
19 ** ------------------------------------------------------------------------
20 **
21 ** THE SOURCE CODE AND THE BINARY OF ARTSAT API IS DISTRIBUTED UNDER THE MIT LICENSE WRITTEN BELOW.
22 ** THE LICENSE OF ANY DATA GOTTEN THROUGH ARTSAT API FOLLOWS PROVIDED LICENSE ON EACH SATELLITE.
23 **
24 ** ARTSAT API のソースコードとバイナリは下記に示す MIT ライセンスの元で配布されます。
25 ** ARTSAT API を通して取得できるデータのライセンスに関してはデータの提供元となる各衛星の定めるライセンスに準じます。
26 **
27 ** The MIT License (MIT)
28 **
29 ** Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
30 ** associated documentation files (the "Software"), to deal in the Software without restriction,
31 ** including without limitation the rights to use, copy, modify, merge, publish, distribute,
32 ** sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
33 ** furnished to do so, subject to the following conditions:
34 ** The above copyright notice and this permission notice shall be included in all copies or
35 ** substantial portions of the Software.
36 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 ** BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
38 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
39 ** WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 **
42 ** 以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を
43 ** 取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。
44 ** これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および、または販売する権利、
45 ** およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
46 ** 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
47 ** ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。
48 ** ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
49 ** 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、
50 ** あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
51 */
52 
53 #ifndef __OFX_SATTIME_H
54 #define __OFX_SATTIME_H
55 
61 #include "ofxSATType.h"
62 #include "ofxSATTimeDiff.h"
63 
65 
127 class ofxSATTime {
128  public:
147  };
148  private:
149  enum SearchEnum {
150  SEARCH_PERCENT,
151  SEARCH_MONTH,
152  SEARCH_MTH,
153  SEARCH_WEEK,
154  SEARCH_WEK,
155  SEARCH_YOUBI,
156  SEARCH_AMPM,
157  SEARCH_GOZENGOGO,
158  SEARCH_LIMIT
159  };
160 
161  private:
162  int _year;
163  int _month;
164  int _day;
165  int _hour;
166  int _minute;
167  int _second;
168  int _days;
169  DayOfWeekEnum _week;
170 
171  public:
176  explicit ofxSATTime (void);
182  ofxSATTime (ofxSATTime const& param);
194  explicit ofxSATTime (int year, int month, int day, int hour, int minute, int second);
205  explicit ofxSATTime (int year, int day, int hour, int minute, int second);
215  explicit ofxSATTime (int year, int hour, int minute, int second);
224  explicit ofxSATTime (int year, int minute, int second);
232  explicit ofxSATTime (int year, int second);
238  explicit ofxSATTime (time_t param);
242  ~ofxSATTime (void);
248  ofxSATTime& operator= (ofxSATTime const& param);
254  ofxSATTime& operator+= (ofxSATTimeDiff const& param);
260  ofxSATTime& operator-= (ofxSATTimeDiff const& param);
266  ofxSATTime& set (ofxSATTime const& param);
278  ofxSATTime& set (int year, int month, int day, int hour, int minute, int second);
305  void get (int* year, int* month, int* day, int* hour, int* minute, int* second, DayOfWeekEnum* week = NULL) const;
316  ofxSATTime& set (int year, int day, int hour, int minute, int second);
340  void get (int* year, int* day, int* hour, int* minute, int* second, DayOfWeekEnum* week = NULL) const;
350  ofxSATTime& set (int year, int hour, int minute, int second);
368  void get (int* year, int* hour, int* minute, int* second) const;
377  ofxSATTime& set (int year, int minute, int second);
392  void get (int* year, int* minute, int* second) const;
400  ofxSATTime& set (int year, int second);
412  void get (int* year, int* second) const;
418  ofxSATTime& set (time_t param);
425  ofxSATTime& setDate (ofxSATTime const& param);
434  ofxSATTime& setDate (int year, int month, int day);
452  void getDate (int* year, int* month, int* day, DayOfWeekEnum* week = NULL) const;
460  ofxSATTime& setDate (int year, int day);
475  void getDate (int* year, int* day, DayOfWeekEnum* week = NULL) const;
482  ofxSATTime& setTime (ofxSATTime const& param);
491  ofxSATTime& setTime (int hour, int minute, int second);
506  int getTime (int* hour, int* minute, int* second) const;
514  ofxSATTime& setTime (int minute, int second);
526  int getTime (int* minute, int* second) const;
533  ofxSATTime& setTime (int second);
542  int getTime (int* second) const;
549  ofxSATTime& setYear (int param);
554  int getYear (void) const;
561  ofxSATTime& setMonth (int param);
566  int getMonth (void) const;
573  ofxSATTime& setDay (int param);
578  int getDay (void) const;
585  ofxSATTime& setHour (int param);
590  int getHour (void) const;
597  ofxSATTime& setMinute (int param);
602  int getMinute (void) const;
609  ofxSATTime& setSecond (int param);
614  int getSecond (void) const;
619  DayOfWeekEnum getDayOfWeek (void) const;
625  ofxSATTime& add (ofxSATTimeDiff const& param);
632  ofxSATTime& addYear (int param);
639  ofxSATTime& addMonth (int param);
646  ofxSATTime& addDay (int param);
653  ofxSATTime& addHour (int param);
660  ofxSATTime& addMinute (int param);
667  ofxSATTime& addSecond (int param);
673  ofxSATTime& sub (ofxSATTimeDiff const& param);
680  ofxSATTime& subYear (int param);
687  ofxSATTime& subMonth (int param);
694  ofxSATTime& subDay (int param);
701  ofxSATTime& subHour (int param);
708  ofxSATTime& subMinute (int param);
715  ofxSATTime& subSecond (int param);
723  bool equals (ofxSATTime const& param) const;
731  bool equalsDate (ofxSATTime const& param) const;
739  bool equalsTime (ofxSATTime const& param) const;
748  int compare (ofxSATTime const& param) const;
757  int compareDate (ofxSATTime const& param) const;
766  int compareTime (ofxSATTime const& param) const;
772  ofxSATTimeDiff difference (ofxSATTime const& param) const;
866  ofxSATError parse (std::string const& format, std::string const& string);
936  std::string format (std::string const& format) const;
941  time_t asTime_t (void) const;
946  static ofxSATTime epochTime (void);
951  static ofxSATTime epochUTCTime (void);
956  static ofxSATTime currentTime (void);
961  static ofxSATTime currentUTCTime (void);
962  private:
963  void from (int year, int month, int day, int hour, int minute, int second, bool truncate);
964  void from (time_t param);
965  time_t to (void) const;
966  static SearchEnum search (std::string const& string, int* index, char* key);
967  static SearchEnum search (std::string const& string, int* index, char* key, int* hint);
968  static void step (std::string const& string, int* index, char* key);
969  static bool compare (std::string const& string, int* index, char const* compare);
970 };
971 
978 extern ofxSATTime operator+ (ofxSATTime const& x, ofxSATTimeDiff const& y);
985 extern ofxSATTime operator- (ofxSATTime const& x, ofxSATTimeDiff const& y);
992 extern ofxSATTimeDiff operator- (ofxSATTime const& x, ofxSATTime const& y);
1001 extern bool operator== (ofxSATTime const& x, ofxSATTime const& y);
1010 extern bool operator!= (ofxSATTime const& x, ofxSATTime const& y);
1019 extern bool operator< (ofxSATTime const& x, ofxSATTime const& y);
1028 extern bool operator<= (ofxSATTime const& x, ofxSATTime const& y);
1037 extern bool operator> (ofxSATTime const& x, ofxSATTime const& y);
1046 extern bool operator>= (ofxSATTime const& x, ofxSATTime const& y);
1047 
1048 /*public */inline ofxSATTime::ofxSATTime(void)
1049 {
1050  set(1970, 1, 1, 0, 0, 0);
1051 }
1052 
1053 /*public */inline ofxSATTime::ofxSATTime(ofxSATTime const& param)
1054 {
1055  set(param);
1056 }
1057 
1058 /*public */inline ofxSATTime::ofxSATTime(int year, int month, int day, int hour, int minute, int second)
1059 {
1060  set(year, month, day, hour, minute, second);
1061 }
1062 
1063 /*public */inline ofxSATTime::ofxSATTime(int year, int day, int hour, int minute, int second)
1064 {
1065  set(year, day, hour, minute, second);
1066 }
1067 
1068 /*public */inline ofxSATTime::ofxSATTime(int year, int hour, int minute, int second)
1069 {
1070  set(year, hour, minute, second);
1071 }
1072 
1073 /*public */inline ofxSATTime::ofxSATTime(int year, int minute, int second)
1074 {
1075  set(year, minute, second);
1076 }
1077 
1078 /*public */inline ofxSATTime::ofxSATTime(int year, int second)
1079 {
1080  set(year, second);
1081 }
1082 
1083 /*public */inline ofxSATTime::ofxSATTime(time_t param)
1084 {
1085  set(param);
1086 }
1087 
1088 /*public */inline ofxSATTime::~ofxSATTime(void)
1089 {
1090 }
1091 
1092 /*public */inline ofxSATTime& ofxSATTime::operator=(ofxSATTime const& param)
1093 {
1094  return set(param);
1095 }
1096 
1097 /*public */inline ofxSATTime& ofxSATTime::operator+=(ofxSATTimeDiff const& param)
1098 {
1099  return add(param);
1100 }
1101 
1102 /*public */inline ofxSATTime& ofxSATTime::operator-=(ofxSATTimeDiff const& param)
1103 {
1104  return sub(param);
1105 }
1106 
1107 /*public */inline int ofxSATTime::getYear(void) const
1108 {
1109  return _year;
1110 }
1111 
1112 /*public */inline int ofxSATTime::getMonth(void) const
1113 {
1114  return _month;
1115 }
1116 
1117 /*public */inline int ofxSATTime::getDay(void) const
1118 {
1119  return _day;
1120 }
1121 
1122 /*public */inline int ofxSATTime::getHour(void) const
1123 {
1124  return _hour;
1125 }
1126 
1127 /*public */inline int ofxSATTime::getMinute(void) const
1128 {
1129  return _minute;
1130 }
1131 
1132 /*public */inline int ofxSATTime::getSecond(void) const
1133 {
1134  return _second;
1135 }
1136 
1138 {
1139  return _week;
1140 }
1141 
1142 /*public */inline time_t ofxSATTime::asTime_t(void) const
1143 {
1144  return to();
1145 }
1146 
1147 inline ofxSATTime operator+(ofxSATTime const& x, ofxSATTimeDiff const& y)
1148 {
1149  return ofxSATTime(x).operator+=(y);
1150 }
1151 
1152 inline ofxSATTime operator-(ofxSATTime const& x, ofxSATTimeDiff const& y)
1153 {
1154  return ofxSATTime(x).operator-=(y);
1155 }
1156 
1157 inline ofxSATTimeDiff operator-(ofxSATTime const& x, ofxSATTime const& y)
1158 {
1159  return x.difference(y);
1160 }
1161 
1162 inline bool operator==(ofxSATTime const& x, ofxSATTime const& y)
1163 {
1164  return x.equals(y);
1165 }
1166 
1167 inline bool operator!=(ofxSATTime const& x, ofxSATTime const& y)
1168 {
1169  return !x.equals(y);
1170 }
1171 
1172 inline bool operator<(ofxSATTime const& x, ofxSATTime const& y)
1173 {
1174  return (x.compare(y) < 0);
1175 }
1176 
1177 inline bool operator<=(ofxSATTime const& x, ofxSATTime const& y)
1178 {
1179  return (x.compare(y) <= 0);
1180 }
1181 
1182 inline bool operator>(ofxSATTime const& x, ofxSATTime const& y)
1183 {
1184  return (x.compare(y) > 0);
1185 }
1186 
1187 inline bool operator>=(ofxSATTime const& x, ofxSATTime const& y)
1188 {
1189  return (x.compare(y) >= 0);
1190 }
1191 
1192 #endif