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