OpenTTD
Functions | Variables
date_func.h File Reference

Functions related to dates. More...

#include "date_type.h"

Go to the source code of this file.

Functions

void SetDate (Date date, DateFract fract)
 Set the date. More...
 
void ConvertDateToYMD (Date date, YearMonthDay *ymd)
 Converts a Date to a Year, Month & Day. More...
 
Date ConvertYMDToDate (Year year, Month month, Day day)
 Converts a tuple of Year, Month and Day to a Date. More...
 
static bool IsLeapYear (Year yr)
 Checks whether the given year is a leap year or not. More...
 

Variables

Year _cur_year
 Current year, starting at 0.
 
Month _cur_month
 Current month (0..11)
 
Date _date
 Current date in days (day counter)
 
DateFract _date_fract
 Fractional part of the day.
 
uint16 _tick_counter
 Ever incrementing (and sometimes wrapping) tick counter for setting off various events.
 

Detailed Description

Functions related to dates.

Definition in file date_func.h.

Function Documentation

◆ ConvertDateToYMD()

void ConvertDateToYMD ( Date  date,
YearMonthDay ymd 
)

Converts a Date to a Year, Month & Day.

Parameters
datethe date to convert from
ymdthe year, month and day to write to

Definition at line 94 of file date.cpp.

References DAYS_IN_YEAR.

Referenced by ClickChangeDateCheat(), SubsidyListWindow::DrawWidget(), CrashLog::FillCrashLog(), GetGlobalVariable(), and GetSnowLine().

◆ ConvertYMDToDate()

Date ConvertYMDToDate ( Year  year,
Month  month,
Day  day 
)

◆ IsLeapYear()

static bool IsLeapYear ( Year  yr)
inlinestatic

Checks whether the given year is a leap year or not.

Parameters
yrThe year to check.
Returns
True if yr is a leap year, otherwise false.

Definition at line 32 of file date_func.h.

Referenced by ConvertYMDToDate(), and GetGlobalVariable().

◆ SetDate()

void SetDate ( Date  date,
DateFract  fract 
)

Set the date.

Parameters
dateNew date
fractThe number of ticks that have passed on this date.

Definition at line 37 of file date.cpp.

Referenced by ClickChangeDateCheat(), and SetStartingYear().