<commit_before>#include "routing/opening_hours_serdes.hpp"

#include "coding/writer.hpp"

#include "base/assert.hpp"
#include "base/scope_guard.hpp"
#include "base/stl_helpers.hpp"

#include <chrono>

namespace
{
uint16_t GetCurrentYear()
{
  auto const now = std::chrono::system_clock::now();
  std::time_t nowCType = std::chrono::system_clock::to_time_t(now);
  auto parts = std::localtime(&nowCType);
  return 1900 + parts->tm_year;
}

osmoh::RuleSequence GetTwentyFourHourRule()
{
  osmoh::Timespan range;

  auto hm = range.GetStart().GetHourMinutes();
  hm.SetHours(osmoh::HourMinutes::THours(0));
  range.GetStart().SetHourMinutes(hm);

  hm = range.GetStart().GetHourMinutes();
  hm.SetHours(osmoh::HourMinutes::THours(24));
  range.GetEnd().SetHourMinutes(hm);

  osmoh::RuleSequence result;
  result.SetTimes({range});
  return result;
}

bool ShouldSkipYear(osmoh::YearRange const & range, uint16_t currentYear)
{
  if (range.GetStart() > range.GetEnd())
    return false;
  
  return range.GetStart() < currentYear && range.GetEnd() < currentYear;
}

bool ShouldSkipYear(osmoh::MonthdayRange const & range, uint16_t currentYear)
{
  auto const hasYear = range.GetStart().HasYear() && range.GetEnd().HasYear();
  if (!hasYear)
    return false;
  
  auto const startYear = range.GetStart().GetYear();
  auto const endYear = range.GetEnd().GetYear();
  if (startYear > endYear)
    return false;

  return hasYear && startYear < currentYear && endYear < currentYear;
}

bool UselessModifier(osmoh::RuleSequence const & rule)
{
  if (rule.GetModifier() == osmoh::RuleSequence::Modifier::Closed ||
      rule.GetModifier() == osmoh::RuleSequence::Modifier::Open)
  {
    return false;
  }
  return true;<commit_msg>[routing] Build map fix. Opening hours restrictions was used when start year is later than end year.<commit_after>#include "routing/opening_hours_serdes.hpp"

#include "coding/writer.hpp"

#include "base/assert.hpp"
#include "base/scope_guard.hpp"
#include "base/stl_helpers.hpp"

#include <chrono>

namespace
{
uint16_t GetCurrentYear()
{
  auto const now = std::chrono::system_clock::now();
  std::time_t nowCType = std::chrono::system_clock::to_time_t(now);
  auto parts = std::localtime(&nowCType);
  return 1900 + parts->tm_year;
}

osmoh::RuleSequence GetTwentyFourHourRule()
{
  osmoh::Timespan range;

  auto hm = range.GetStart().GetHourMinutes();
  hm.SetHours(osmoh::HourMinutes::THours(0));
  range.GetStart().SetHourMinutes(hm);

  hm = range.GetStart().GetHourMinutes();
  hm.SetHours(osmoh::HourMinutes::THours(24));
  range.GetEnd().SetHourMinutes(hm);

  osmoh::RuleSequence result;
  result.SetTimes({range});
  return result;
}

bool ShouldSkipYear(osmoh::YearRange const & range, uint16_t currentYear)
{
  if (range.GetStart() > range.GetEnd())
    return true;
  
  return range.GetStart() < currentYear && range.GetEnd() < currentYear;
}

bool ShouldSkipYear(osmoh::MonthdayRange const & range, uint16_t currentYear)
{
  auto const hasYear = range.GetStart().HasYear() && range.GetEnd().HasYear();
  if (!hasYear)
    return true;
  
  auto const startYear = range.GetStart().GetYear();
  auto const endYear = range.GetEnd().GetYear();
  if (startYear > endYear)
    return true;

  return hasYear && startYear < currentYear && endYear < currentYear;
}

bool UselessModifier(osmoh::RuleSequence const & rule)
{
  if (rule.GetModifier() == osmoh::RuleSequence::Modifier::Closed ||
      rule.GetModifier() == osmoh::RuleSequence::Modifier::Open)
  {
    return false;
  }
  return true;
{'fraction_non_alphanumeric': 0.14730878186968838, 'fraction_numerical': 0.0073654390934844195, 'mean_word_length': 5.249557522123894, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5033662', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1230, 'n_words': 233}