Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Hall Of Fame
Housekeeping, cleaning up
Image Management In Gambas
Including Help Comments in Source Code
Interpreter limits
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
Localisation and Internationalization
Mailing Lists & Forums
Naming Conventions
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Screenshots
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Variable Naming Convention
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

Dates and calendars

Gambas uses the Gregorian calendar

Wikipedia tells us:

"The Gregorian calendar is the calendar used in most of the world. It was introduced in October 1582 by Pope Gregory XIII as a minor modification of the Julian calendar, reducing the average year from 365.25 days to 365.2425 days, thus correcting for the drift against the solar year that the inaccuracy had caused during the intervening centuries..."

It's better to assume that every country and every people use their own calendar system, which do not match day to day. Because some follows the Sun, other the Moon, count months differently, years differently, begin the day the morning or the evening, have some holes in the calendar similar to the Julian/Gregorian transition, and so on... The human imagination has no limit.

The Gregorian calendar is now more or less understood by most of the world, so it is a good candidate to be what Coordinated Universal Time (UTC) is for time.

Gambas almost uses the Gregorian calendar!

In Gambas, the date is internally stored as a number of day since January 1st 4801 BC.

But this date is actually a date of the Gregorian calendar extended to the past. Because the Gregorian calendar was adopted October 15th 1582, at least in the Catholic European world.

In other words:

  • October 15th 1582, and following days are exact.

  • The day before October 15th 1582 is not October 4th 1582 of the Julian calendar, but October 14th 1582. And so on.

This is by design: conversion between integers and dates, and date arithmetic have been favored for the sake of performance and simplicity.

Beware that in that extended Gregorian calendar, there is no year 0. The year following 1 BC is 1 AC.

Consequences

You have to be careful when using the WeekDay function. As soon as your date is lower than October 15th 1582, the returned day is false.

You have to be careful too that the Gregorian calendar was adopted at different moments according to the country: for example, William Shakespeare and Miguel de Cervantes seemingly died on exactly the same date (April 23rd 1616), but Cervantes predeceased Shakespeare by ten days in real time (as Spain used the Gregorian calendar, but Britain used the Julian calendar).

The DateChooser control does not handle specific calendars. This could be an interesting development to do: adding support for different calendars, with transparent conversion between Gambas dates and local dates.

See also