year

Overview

Provides functions to interpret an year value.

Functions

overall

century_c

int32_t century_c( int32_t year );

Returns the century part of an year value.

Example
#include "clingo/lang/expect.h"
#include "clingo/time/year.h"

int main( void )
{
   init_tap_c_();

   expect_c_( century_c( 1492 ) == 14 );
   expect_c_( century_c( 2021 ) == 20 );

   return finish_tap_c_();
}

days_of_year_c

int16_t days_of_year_c( int32_t year );

Returns the number of days the year has.

Example
#include "clingo/lang/expect.h"
#include "clingo/time/year.h"

int main( void )
{
   init_tap_c_();

   expect_c_( days_of_year_c( 1800 ) == 365 );
   expect_c_( days_of_year_c( 1996 ) == 366 );
   expect_c_( days_of_year_c( 2000 ) == 366 );
   expect_c_( days_of_year_c( 2021 ) == 365 );

   return finish_tap_c_();
}

is_leap_year_c

bool is_leap_year_c( int32_t year );

Returns true if the year is a leap year, otherwise false.

Example
#include "clingo/lang/expect.h"
#include "clingo/time/year.h"

int main( void )
{
   init_tap_c_();

   expect_c_( !is_leap_year_c( 1800 ) );
   expect_c_(  is_leap_year_c( 1996 ) );
   expect_c_(  is_leap_year_c( 2000 ) );
   expect_c_( !is_leap_year_c( 2021 ) );

   return finish_tap_c_();
}

year_in_century_c

int32_t year_in_century_c( int32_t year );

Returns the year in the century.

Example
#include "clingo/lang/expect.h"
#include "clingo/time/year.h"

int main( void )
{
   init_tap_c_();

   expect_c_( year_in_century_c( 1492 ) == 92 );
   expect_c_( year_in_century_c( 2021 ) == 21 );

   return finish_tap_c_();
}