1*f42644c3SDamjan Jovanovic /**************************************************************
2*f42644c3SDamjan Jovanovic  *
3*f42644c3SDamjan Jovanovic  * Licensed to the Apache Software Foundation (ASF) under one
4*f42644c3SDamjan Jovanovic  * or more contributor license agreements.  See the NOTICE file
5*f42644c3SDamjan Jovanovic  * distributed with this work for additional information
6*f42644c3SDamjan Jovanovic  * regarding copyright ownership.  The ASF licenses this file
7*f42644c3SDamjan Jovanovic  * to you under the Apache License, Version 2.0 (the
8*f42644c3SDamjan Jovanovic  * "License"); you may not use this file except in compliance
9*f42644c3SDamjan Jovanovic  * with the License.  You may obtain a copy of the License at
10*f42644c3SDamjan Jovanovic  *
11*f42644c3SDamjan Jovanovic  *   http://www.apache.org/licenses/LICENSE-2.0
12*f42644c3SDamjan Jovanovic  *
13*f42644c3SDamjan Jovanovic  * Unless required by applicable law or agreed to in writing,
14*f42644c3SDamjan Jovanovic  * software distributed under the License is distributed on an
15*f42644c3SDamjan Jovanovic  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f42644c3SDamjan Jovanovic  * KIND, either express or implied.  See the License for the
17*f42644c3SDamjan Jovanovic  * specific language governing permissions and limitations
18*f42644c3SDamjan Jovanovic  * under the License.
19*f42644c3SDamjan Jovanovic  *
20*f42644c3SDamjan Jovanovic  *************************************************************/
21*f42644c3SDamjan Jovanovic 
22*f42644c3SDamjan Jovanovic #include "oox/helper/datetimehelper.hxx"
23*f42644c3SDamjan Jovanovic 
24*f42644c3SDamjan Jovanovic namespace oox {
25*f42644c3SDamjan Jovanovic 
26*f42644c3SDamjan Jovanovic // ============================================================================
27*f42644c3SDamjan Jovanovic 
28*f42644c3SDamjan Jovanovic using namespace ::com::sun::star::util;
29*f42644c3SDamjan Jovanovic 
30*f42644c3SDamjan Jovanovic using ::rtl::OUString;
31*f42644c3SDamjan Jovanovic 
32*f42644c3SDamjan Jovanovic // ============================================================================
33*f42644c3SDamjan Jovanovic 
34*f42644c3SDamjan Jovanovic bool parseISO8601DateTime( OUString &aValue, DateTime &dateTime )
35*f42644c3SDamjan Jovanovic {
36*f42644c3SDamjan Jovanovic     bool bValid = (aValue.getLength() >= 19) && (aValue[ 4 ] == '-') && (aValue[ 7 ] == '-') &&
37*f42644c3SDamjan Jovanovic         (aValue[ 10 ] == 'T') && (aValue[ 13 ] == ':') && (aValue[ 16 ] == ':');
38*f42644c3SDamjan Jovanovic     if( bValid )
39*f42644c3SDamjan Jovanovic     {
40*f42644c3SDamjan Jovanovic         dateTime.Year    = static_cast< sal_uInt16 >( aValue.copy( 0, 4 ).toInt32() );
41*f42644c3SDamjan Jovanovic         dateTime.Month   = static_cast< sal_uInt16 >( aValue.copy( 5, 2 ).toInt32() );
42*f42644c3SDamjan Jovanovic         dateTime.Day     = static_cast< sal_uInt16 >( aValue.copy( 8, 2 ).toInt32() );
43*f42644c3SDamjan Jovanovic         dateTime.Hours   = static_cast< sal_uInt16 >( aValue.copy( 11, 2 ).toInt32() );
44*f42644c3SDamjan Jovanovic         dateTime.Minutes = static_cast< sal_uInt16 >( aValue.copy( 14, 2 ).toInt32() );
45*f42644c3SDamjan Jovanovic         double seconds = aValue.copy( 17 ).toDouble();
46*f42644c3SDamjan Jovanovic         dateTime.Seconds = static_cast< sal_uInt16 >( floor( seconds ) );
47*f42644c3SDamjan Jovanovic         dateTime.HundredthSeconds = static_cast< sal_uInt16 >( round ( 100 * ( seconds - floor( seconds ) ) ) );
48*f42644c3SDamjan Jovanovic     }
49*f42644c3SDamjan Jovanovic     return bValid;
50*f42644c3SDamjan Jovanovic }
51*f42644c3SDamjan Jovanovic 
52*f42644c3SDamjan Jovanovic // ============================================================================
53*f42644c3SDamjan Jovanovic 
54*f42644c3SDamjan Jovanovic } // namespace oox
55