Skip to content

jcore date

Julius Paffrath edited this page Jul 11, 2026 · 8 revisions

Introduction

The date module offers functions for date manipulation. Please note that this module does not support handling timezones. For passing and processing dates, a date struct is offered, containing fields for year, month and day:

use "jcore/date" as date
set myDate to date::Date(year = 2026, month = 10, day = 28)

checkIfYearIsLeapYear(year: number)

Returns true, if the passed year is a leap year.

getDateFromElapsedSeconds(elapsedSeconds: number)

Accepts unix time seconds and calculates based on these a date struct containing the corresponding day in time. The function supports negative unix time seconds for handling date before the 01.01.1970.

getElapsedSecondsFromDate(date: Date)

Accepts a date struct and calculates based on this a number of seconds since unix time. If the passed date if before unix time, the number of elapsed seconds will be negative.

isDateAfter(date1: Date, date2: Date)

Returns true if date1 is after date2.

isDateBefore(date1: Date, date2: Date)

Returns true if date1 is before date2.

addDays(date: Date, days: number)

Returns a new date with the given days added or nil if days is negative.

subtractDays(date: Date, days: number)

Returns a new date with the given days subtracted or nil if days is negative.

getDifferenceBetweenDates(date1: Date, date2: Date)

Returns the difference between two dates in seconds.

getDayOfWeek(date: Date)

Returns the day of the week for a given date. 1 = Monday, 2 = Tuesday, ...

getWeekOfYear(date: Date)

Returns the ISO 8601 week number for a given date.

stringFrom(date: Date)

A simple function for pretty printing a date struct.

print(date: Date)

Override the print function for pretty printing dates.

printLine(date: Date)

Override the printLine function for pretty printing dates with a newline.

Clone this wiki locally