15# pragma warning (disable: 4996)
58 bool greg = gregorian(y, m, d);
59 y += (m + 9) / 12 - 1;
67 + (greg ? (y / 100) / 4 - (y / 100) + 2 : 0)
80 if (!(s > 0 && y == y1 && m == m1 && d == d1))
85 " before 0001-01-01"));
91 bool greg = gregorian(s);
97 c = (4 * s + 3) / 146097;
98 s -= (c * 146097) / 4;
100 y = (4 * s + 3) / 1461;
103 m = (5 * s + 2) / 153;
104 s -= (153 * m + 2) / 5;
107 m = (m + 2) % 12 + 1;
113 struct tm* now = gmtime(&t);
114 y = now->tm_year + 1900;
119 int y1, m1 = 1, d1 = 1;
120 const char* digits =
"0123456789";
121 string::size_type p1 = s.find_first_not_of(digits);
122 if (p1 == string::npos)
124 else if (s[p1] !=
'-')
129 y1 = val<int>(s.substr(0, p1));
130 if (++p1 == s.size())
132 string::size_type p2 = s.find_first_not_of(digits, p1);
133 if (p2 == string::npos)
134 m1 = val<int>(s.substr(p1));
135 else if (s[p2] !=
'-')
140 m1 = val<int>(s.substr(p1, p2 - p1));
141 if (++p2 == s.size())
143 d1 = val<int>(s.substr(p2));
146 y = y1; m = m1; d = d1;
152 end = unsigned(s.size());
153 while (beg < end && isspace(s[beg]))
155 while (beg < end && isspace(s[end - 1]))
157 return string(s, beg, end-beg);
161 string::size_type r = s.find(
char(toupper(c)));
162 return r == string::npos ? -1 : int(r);
166 const char* p = strchr(s, toupper(c));
167 return p != NULL ? int(p - s) : -1;
171 std::string& key, std::string& value,
172 char equals,
char comment) {
173 key.clear(); value.clear();
174 string::size_type n = comment ? line.find(comment) : line.size();
175 string linea =
trim(line.substr(0, n));
176 if (linea.empty())
return false;
177 n = equals ? linea.find(equals) : linea.find_first_of(
" \t\n\v\f\r");
178 key =
trim(linea.substr(0, n));
179 if (key.empty())
return false;
180 if (n != string::npos) value =
trim(linea.substr(n + 1));
185#if GEOGRAPHICLIB_PRECISION == 5
187 char* digitenv = getenv(
"GEOGRAPHICLIB_DIGITS");
189 ndigits = strtol(digitenv, NULL, 0);
Header for GeographicLib::Utility class.
Exception handling for GeographicLib.
static int set_digits(int ndigits)
static void date(int s, int &y, int &m, int &d)
static int lookup(const std::string &s, char c)
static bool ParseLine(const std::string &line, std::string &key, std::string &value, char equals='\0', char comment='#')
static int set_digits(int ndigits=0)
static std::string trim(const std::string &s)
static int day(int y, int m=1, int d=1)
static std::string str(T x, int p=-1)
Namespace for GeographicLib.