RealDocs

UKismetMathLibrary::DaysInYear

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPure

Description

Returns 366 for leap years and 365 for all other years. Delegates to FDateTime::DaysInYear().

Caveats & Gotchas

  • UE uses the proleptic Gregorian calendar — years before 1582 follow Gregorian leap-year rules even though the Gregorian calendar wasn't adopted then. Results for historical dates may not match records from that era.
  • Year 0 is not a valid FDateTime year (valid range is 1–9999). Passing 0 or a negative year produces an incorrect result without an assertion in Shipping builds.

Signature

static UE_INL_API int32 DaysInYear( int32 Year );

Parameters

Name Type Description Default
Year int32 The year to query (1–9999).

Return Type

int32

Example

Calculate fraction of year elapsed C++
FDateTime Now = FDateTime::Now();
int32 DayOfYear = Now.GetDayOfYear();
int32 TotalDays = UKismetMathLibrary::DaysInYear(Now.GetYear());
float Fraction = (float)DayOfYear / (float)TotalDays;

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.