11f71f1d8SDamjan Jovanovic /************************************************************** 21f71f1d8SDamjan Jovanovic * 31f71f1d8SDamjan Jovanovic * Licensed to the Apache Software Foundation (ASF) under one 41f71f1d8SDamjan Jovanovic * or more contributor license agreements. See the NOTICE file 51f71f1d8SDamjan Jovanovic * distributed with this work for additional information 61f71f1d8SDamjan Jovanovic * regarding copyright ownership. The ASF licenses this file 71f71f1d8SDamjan Jovanovic * to you under the Apache License, Version 2.0 (the 81f71f1d8SDamjan Jovanovic * "License"); you may not use this file except in compliance 91f71f1d8SDamjan Jovanovic * with the License. You may obtain a copy of the License at 101f71f1d8SDamjan Jovanovic * 111f71f1d8SDamjan Jovanovic * http://www.apache.org/licenses/LICENSE-2.0 121f71f1d8SDamjan Jovanovic * 131f71f1d8SDamjan Jovanovic * Unless required by applicable law or agreed to in writing, 141f71f1d8SDamjan Jovanovic * software distributed under the License is distributed on an 151f71f1d8SDamjan Jovanovic * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 161f71f1d8SDamjan Jovanovic * KIND, either express or implied. See the License for the 171f71f1d8SDamjan Jovanovic * specific language governing permissions and limitations 181f71f1d8SDamjan Jovanovic * under the License. 191f71f1d8SDamjan Jovanovic * 201f71f1d8SDamjan Jovanovic *************************************************************/ 211f71f1d8SDamjan Jovanovic 221f71f1d8SDamjan Jovanovic #include "oox/helper/datetimehelper.hxx" 231f71f1d8SDamjan Jovanovic 24*ab427ea7SDamjan Jovanovic #include <math.h> 25*ab427ea7SDamjan Jovanovic 261f71f1d8SDamjan Jovanovic namespace oox { 271f71f1d8SDamjan Jovanovic 281f71f1d8SDamjan Jovanovic // ============================================================================ 291f71f1d8SDamjan Jovanovic 301f71f1d8SDamjan Jovanovic using namespace ::com::sun::star::util; 311f71f1d8SDamjan Jovanovic 321f71f1d8SDamjan Jovanovic using ::rtl::OUString; 331f71f1d8SDamjan Jovanovic 341f71f1d8SDamjan Jovanovic // ============================================================================ 351f71f1d8SDamjan Jovanovic 361f71f1d8SDamjan Jovanovic bool parseISO8601DateTime( OUString &aValue, DateTime &dateTime ) 371f71f1d8SDamjan Jovanovic { 381f71f1d8SDamjan Jovanovic bool bValid = (aValue.getLength() >= 19) && (aValue[ 4 ] == '-') && (aValue[ 7 ] == '-') && 391f71f1d8SDamjan Jovanovic (aValue[ 10 ] == 'T') && (aValue[ 13 ] == ':') && (aValue[ 16 ] == ':'); 401f71f1d8SDamjan Jovanovic if( bValid ) 411f71f1d8SDamjan Jovanovic { 421f71f1d8SDamjan Jovanovic dateTime.Year = static_cast< sal_uInt16 >( aValue.copy( 0, 4 ).toInt32() ); 431f71f1d8SDamjan Jovanovic dateTime.Month = static_cast< sal_uInt16 >( aValue.copy( 5, 2 ).toInt32() ); 441f71f1d8SDamjan Jovanovic dateTime.Day = static_cast< sal_uInt16 >( aValue.copy( 8, 2 ).toInt32() ); 451f71f1d8SDamjan Jovanovic dateTime.Hours = static_cast< sal_uInt16 >( aValue.copy( 11, 2 ).toInt32() ); 461f71f1d8SDamjan Jovanovic dateTime.Minutes = static_cast< sal_uInt16 >( aValue.copy( 14, 2 ).toInt32() ); 471f71f1d8SDamjan Jovanovic double seconds = aValue.copy( 17 ).toDouble(); 481f71f1d8SDamjan Jovanovic dateTime.Seconds = static_cast< sal_uInt16 >( floor( seconds ) ); 491f71f1d8SDamjan Jovanovic dateTime.HundredthSeconds = static_cast< sal_uInt16 >( round ( 100 * ( seconds - floor( seconds ) ) ) ); 501f71f1d8SDamjan Jovanovic } 511f71f1d8SDamjan Jovanovic return bValid; 521f71f1d8SDamjan Jovanovic } 531f71f1d8SDamjan Jovanovic 541f71f1d8SDamjan Jovanovic // ============================================================================ 551f71f1d8SDamjan Jovanovic 561f71f1d8SDamjan Jovanovic } // namespace oox 57