/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// 32767-12-31 in "(days since 0001-01-01) + 1" format const sal_Int32 maxDays = 11967896; // -32768-01-01 in "(days since 0001-01-01) + 1" format // Yes, I know it is currently unused. Will have to be used // when we implement negative years. Writing down the correct // value for future reference. // *** Please don't remove just because it is unused *** // Lionel Élie Mamane 2017-08-02 // const sal_Int32 minDays = -11968270;
}
static sal_Int32 implRelativeToAbsoluteNull(const css::util::Date& _rDate)
{ if (_rDate.Day == 0 && _rDate.Month == 0 && _rDate.Year == 0)
{ // 0000-00-00 is *NOT* a valid date and passing it to the date // conversion even when normalizing rightly asserts. Whatever we // return here, it will be wrong. The old before commit // 52ff16771ac160d27fd7beb78a4cfba22ad84f06 wrong implementation // calculated -365 for that, effectively that would be a date of // -0001-01-01 now but it was likely assumed that would be // 0000-00-01 or even 0000-00-00 instead. Try if we get away with 0 // for -0001-12-31, the same that // comphelper::date::convertDateToDaysNormalizing() // would return if comphelper::date::normalize() wouldn't ignore // such "empty" date.
css::util::Time aRet; // normalize time // we have to sal_Int32 here because otherwise we get an overflow
sal_Int64 nNanoSeconds = nNS;
sal_Int32 nSeconds = nNanoSeconds / nanoSecInSec;
sal_Int32 nMinutes = nSeconds / secInMin;
if (!std::isfinite(dVal))
{
SAL_WARN("connectivity.commontools", "DateTime has invalid value: " << dVal); return aRet;
}
css::util::Date aDate = toDate(dVal, _rNullDate); // there is not enough precision in a double to have both a date // and a time up to nanoseconds -> limit to microseconds to have // correct rounding, that is e.g. 13:00:00.000000000 instead of // 12:59:59.999999790
css::util::Time aTime = toTime(dVal, 6);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.