/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// activitygen module4// Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)5// This program and the accompanying materials are made available under the6// terms of the Eclipse Public License 2.0 which is available at7// https://www.eclipse.org/legal/epl-2.0/8// This Source Code may also be made available under the following Secondary9// Licenses when the conditions for such availability set forth in the Eclipse10// Public License 2.0 are satisfied: GNU General Public License, version 211// or later which is available at12// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html13// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later14/****************************************************************************/15/// @file AGTime.cpp16/// @author Piotr Woznica17/// @author Daniel Krajzewicz18/// @author Michael Behrisch19/// @author Walter Bamberger20/// @date July 201021///22// Time manager: able to manipulate the time using Sumo's format (seconds)23/****************************************************************************/24#include <config.h>2526#include "AGTime.h"272829// ===========================================================================30// method definitions31// ===========================================================================32AGTime::AGTime(const AGTime& time) {33mySeconds = time.mySeconds;34}3536int37AGTime::convert(int days, int hours, int minutes, int seconds) {38mySeconds = seconds + 60 * (minutes + 60 * (hours + 24 * (days)));39return mySeconds;40}4142int43AGTime::getSecondsOf(double minutes) {44return static_cast<int>(60.0 * minutes);45}4647bool48AGTime::operator==(const AGTime& time) {49if (this->mySeconds == time.mySeconds) {50return true;51} else {52return false;53}54}5556bool57AGTime::operator<(const AGTime& time) {58if (this->mySeconds < time.mySeconds) {59return true;60} else {61return false;62}63}6465bool66AGTime::operator<=(const AGTime& time) {67if (this->mySeconds <= time.mySeconds) {68return true;69} else {70return false;71}72}7374void75AGTime::operator+=(const AGTime& time) {76this->mySeconds += time.mySeconds;77}7879void80AGTime::operator+=(int seconds) {81this->mySeconds += seconds;82}8384void85AGTime::operator-=(const AGTime& time) {86this->mySeconds -= time.mySeconds;87}8889AGTime90AGTime::operator+(const AGTime& time) {91AGTime newtime(time.mySeconds + this->mySeconds);92return newtime;93}9495int96AGTime::getDay() {97return (mySeconds / 86400);98}99100int101AGTime::getHour() {102return ((mySeconds / 3600) % 24);103}104105int106AGTime::getMinute() {107return ((mySeconds / 60) % 60);108}109110int111AGTime::getSecond() {112return (mySeconds % 60);113}114115int116AGTime::getSecondsInCurrentDay() {117return (mySeconds % 86400);118}119120int121AGTime::getTime() {122return this->mySeconds;123}124125void126AGTime::setDay(int d) {127if (0 <= d) {128mySeconds -= 86400 * getDay();129mySeconds += 86400 * d;130}131}132133void134AGTime::setHour(int h) {135if (0 <= h && h < 24) {136mySeconds -= 3600 * getHour();137mySeconds += 3600 * h;138}139}140141void142AGTime::setMinute(int m) {143if (0 <= m && m < 60) {144mySeconds -= 60 * getMinute();145mySeconds += 60 * m;146}147}148149void150AGTime::setSecond(int s) {151if (0 <= s && s < 60) {152mySeconds -= getSecond();153mySeconds += s;154}155}156157void158AGTime::setTime(int seconds) {159mySeconds = seconds;160}161162void163AGTime::addDays(int d) {164mySeconds += 86400 * d;165}166167void168AGTime::addHours(int h) {169mySeconds += 3600 * h;170}171172void173AGTime::addMinutes(int m) {174mySeconds += 60 * m;175}176177void178AGTime::addSeconds(int s) {179mySeconds += s;180}181182183/****************************************************************************/184185186