21#include <com/sun/star/util/DateTime.hpp>
28bool DateTimeHelper::ISO8601_To_DateTime (std::u16string_view s,
33 int year,
month,
day, hours, minutes, off_hours, off_minutes, fix;
37 int n = sscanf( aDT.getStr(),
"%04d-%02d-%02dT%02d:%02d:%lfZ",
46 n = sscanf( aDT.getStr(),
"%04d-%02d-%02dT%02d:%02d:%lf+%02d:%02d",
48 &off_hours, &off_minutes );
51 fix = - off_hours * 3600 - off_minutes * 60;
56 n = sscanf( aDT.getStr(),
"%04d-%02d-%02dT%02d:%02d:%lf-%02d:%02d",
58 &off_hours, &off_minutes );
61 fix = off_hours * 3600 + off_minutes * 60;
72 oslDateTime aDateTime;
73 aDateTime.NanoSeconds = 0;
74 aDateTime.Seconds = sal::static_int_cast< sal_uInt16 >(seconds);
75 aDateTime.Minutes = sal::static_int_cast< sal_uInt16 >(minutes);
76 aDateTime.Hours = sal::static_int_cast< sal_uInt16 >(hours);
77 aDateTime.Day = sal::static_int_cast< sal_uInt16 >(
day);
78 aDateTime.DayOfWeek = 0;
79 aDateTime.Month = sal::static_int_cast< sal_uInt16 >(
month);
80 aDateTime.Year = sal::static_int_cast< sal_Int16 >(
year);
83 if ( osl_getTimeValueFromDateTime( &aDateTime, &aTimeValue ) )
85 aTimeValue.Seconds += fix;
87 if ( osl_getLocalTimeFromSystemTime( &aTimeValue, &aTimeValue ) )
89 if ( osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime ) )
91 dateTime.Year = aDateTime.Year;
92 dateTime.Month = aDateTime.Month;
93 dateTime.Day = aDateTime.Day;
94 dateTime.Hours = aDateTime.Hours;
95 dateTime.Minutes = aDateTime.Minutes;
96 dateTime.Seconds = aDateTime.Seconds;
166 char string_month[3 + 1];
167 char string_day[3 + 1];
169 size_t found = s.find(
',');
170 if (found != std::u16string_view::npos)
175 found = sscanf (aDT.getStr(),
"%3s, %2d %3s %4d %2d:%2d:%2d GMT",
176 string_day, &
day, string_month, &
year, &hours, &minutes, &seconds);
180 found = sscanf (aDT.getStr(),
"%3s, %2d-%3s-%2d %2d:%2d:%2d GMT",
181 string_day, &
day, string_month, &
year, &hours, &minutes, &seconds);
183 found = (found == 7) ? 1 : 0;
190 found = sscanf (aDT.getStr(),
"%3s %3s %d %2d:%2d:%2d %4d",
191 string_day, string_month,
192 &
day, &hours, &minutes, &seconds, &
year);
193 found = (found == 7) ? 1 : 0;
201 OUString::createFromAscii (string_month));
206 oslDateTime aDateTime;
207 aDateTime.NanoSeconds = 0;
208 aDateTime.Seconds = sal::static_int_cast< sal_uInt16 >(seconds);
210 aDateTime.Minutes = sal::static_int_cast< sal_uInt16 >(minutes);
212 aDateTime.Hours = sal::static_int_cast< sal_uInt16 >(hours);
214 aDateTime.Day = sal::static_int_cast< sal_uInt16 >(
day);
216 aDateTime.DayOfWeek = 0;
217 aDateTime.Month = sal::static_int_cast< sal_uInt16 >(
month);
219 aDateTime.Year = sal::static_int_cast< sal_Int16 >(
year);
221 TimeValue aTimeValue;
222 if ( osl_getTimeValueFromDateTime( &aDateTime,
225 if ( osl_getLocalTimeFromSystemTime( &aTimeValue,
228 if ( osl_getDateTimeFromTimeValue( &aTimeValue,
231 dateTime.Year = aDateTime.Year;
232 dateTime.Month = aDateTime.Month;
233 dateTime.Day = aDateTime.Day;
234 dateTime.Hours = aDateTime.Hours;
235 dateTime.Minutes = aDateTime.Minutes;
236 dateTime.Seconds = aDateTime.Seconds;
static bool RFC2068_To_DateTime(std::u16string_view, css::util::DateTime &)
static bool ISO8601_To_DateTime(std::u16string_view, css::util::DateTime &)
static bool convert(std::u16string_view, css::util::DateTime &)
static sal_Int32 convertMonthToInt(std::u16string_view month)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)