Datum

paket "datumvrijeme";

The datum package provides a way to work with local dates.

Package functions

datumVrijemeSada

The datumVrijemeSada function returns a DatumVrijeme object representing the current date from the system clock in the default time-zone.

ƒ datumVrijemeSada () : objekat
var now = datumVrijemeSada();
ispis(now.danMjeseca, ".", now.mjesec, ".", now.godina);
ispis(now.sati, ":", now.minute, ":", now.sekunde);
16.5.2023
14:43:51

datumVrijemeIzTeksta

The datumVrijemeIzTeksta function parses a DatumVrijeme object out of a provided tekst in the dd.MM.yyyy HH:mm:ss format.

ƒ datumVrijemeIzTeksta (str: tekst) : objekat
var date = datumVrijemeIzTeksta("26.05.2023 14:44:00");
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
26.5.2023

Invalid tekst example:

var time = datumVrijemeIzTeksta("31.2.2023");
Error: Cannot parse DatumVrijeme from tekst "31.2.2023"

datumVrijemePoFormatu

The datumVrijemePoFormatu function parses a DatumVrijeme object out of a provided tekst according to the provided format.

ƒ datumVrijemePoFormatu (str: tekst, format: tekst) : objekat
var date = datumVrijemePoFormatu("11/10/2000", "dd/MM/yyyy");
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
11.10.2000

Invalid date example:

var date = datumVrijemeIzTeksta("96/10/2000", "dd/MM/yyyy");
Error: Cannot parse DatumVrijeme from tekst "96/10/2000".

Invalid format example:

var date = datumVrijemeIzTeksta("11/10/2000", "yy/YY/yyyy");
Error: 'yy/YY/yyyy' is not a valid time format.
28.8.2023

DatumVrijeme constructor

You can use the DatumVrijeme constructor to construct a DatumVrijeme object by providing a value for day, month and year.

ƒ DatumVrijeme (
    day: broj,
    month: broj,
    year: broj,
    hour: broj,
    minute: broj
) : objekat
var date = DatumVrijeme(28:, 8:, 2023:, 12:, 15:);

ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
28.8.2023

puniDatum

The puniDatum function gives you more control than the DatumVrijeme constructor. It allows you to provide values for seconds and nanoseconds.

ƒ puniDatum (
    day: broj, 
    month: broj, 
    year: broj, 
    hour: broj, 
    minute: broj, 
    seconds: broj, 
    nanoseconds: broj
) : objekat
var date = DatumVrijeme(28:, 8:, 2023:, 12:, 15:);

ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);

DatumVrijeme object

godina

The godina property is a broj holding the year part of the DatumVrijeme object.

var date = DatumVrijeme(11:,10:,2023:, 12:, 15:);
ispis(date.godina);
Output:

2000

mjesec

The godina property is a broj holding the year part of the DatumVrijeme object.

var date = DatumVrijeme(11:,10:,2023:, 12:, 15:);
ispis(date.mjesec);
Output:

10:

danGodine

The danGodine property is a broj holding the day-of-year field of the DatumVrijeme object.

var date = DatumVrijeme(11:,10:,2023:, 12:, 15:);
ispis(date.danGodine);
Output:

284:

danMjeseca

The danMjeseca property is a broj holding the day-of-month field of the DatumVrijeme object. This is the day part of the date you will usually need.

var date = DatumVrijeme(11:,10:,2023:, 12:, 15:);
ispis(date.danMjeseca);
Output:

11:

danSedmice

The danSedmice property is a broj holding the day-of-week field of the DatumVrijeme object, starting from 1 for Monday.

var date = DatumVrijeme(11:,10:,2000:, 12:, 15:);
ispis(date.danSedmice);
Output:

3:

sati

The sati property is a broj holding the hours part of the DatumVrijeme object.

var v = DatumVrijeme(11:, 10:, 2023:, 15:, 22:, 0:);

ispis(v.sati);
15:

minute

The minute property is a broj holding the minutes part of the DatumVrijeme object.

var v = DatumVrijeme(11:, 10:, 2023:, 15:, 22:, 0:);

ispis(v.minute);
22:

sekunde

The sekunde property is a broj holding the seconds part of the DatumVrijeme object.

var v = DatumVrijeme(11:, 10:, 2023:, 15:, 22:, 33:);

ispis(v.sekunde);
33:

nanosekunde

The nanosekunde property is a broj holding the nanoseconds part of the DatumVrijeme object.

var v = DatumVrijeme(11:, 10:, 2023:, 15:, 22:, 33:);

ispis(v.nanosekunde);
0:

plusSati

The plusSati function returns a copy of the calling DatumVrijeme object with the specified number of hours added. The original DatumVrijeme object remains unchanged.

ƒ plusSati (hours: broj) : objekat
var v = DatumVrijeme(11:, 10:, 2023:, 15:, 22:, 33:);

var nv = v.plusSati(2:);
ispis(nv.sati, ":", nv.minute);
17:22

minusSati

The minusSati function returns a copy of the calling DatumVrijeme object with the specified number of hours subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusSati (hours: broj) : objekat
var v = DatumVrijeme(11:, 10:, 2023:, 15:, 22:, 33:);

var nv = v.minusSati(2:);
ispis(nv.sati, ":", nv.minute);
13:22

plusMinuta

The plusMinuta function returns a copy of the calling DatumVrijeme object with the specified number of minutes added. The original DatumVrijeme object remains unchanged.

ƒ plusMinuta (minutes: broj) : objekat
var v = DatumVrijeme(11, 10, 2023, 15, 22, 33);

var nv = v.plusMinuta(23);
ispis(nv.sati, ":", nv.minute);
15:45

minusMinuta

The minusMinuta function returns a copy of the calling DatumVrijeme object with the specified number of minutes subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusMinuta (minutes: broj) : objekat
var v = DatumVrijeme(11, 10, 2023, 15, 22, 33);

var nv = v.minusMinuta(22);
ispis(nv.sati, ":", nv.minute);
15:00

plusSekundi

The plusSekundi function returns a copy of the calling DatumVrijeme object with the specified number of minutes added. The original DatumVrijeme object remains unchanged.

ƒ plusSekundi (seconds: broj) : objekat
var v = DatumVrijeme(11, 10, 2023, 15, 22, 33);

var nv = v.plusSekundi(23);
ispis(nv.sati, ":", nv.minute, ":", nv.sekunde);
15:22:56

minusSekundi

The minusSekundi function returns a copy of the calling DatumVrijeme object with the specified number of minutes subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusSekundi (seconds: broj) : objekat
var v = DatumVrijeme(11, 10, 2023, 15, 22, 33);

var nv = v.minusSekundi(22);
ispis(nv.sati, ":", nv.minute, ":", nv.sekunde);
15:22:11

plusNanoSekundi

The plusNanoSekundi function returns a copy of the calling DatumVrijeme object with the specified number of nanoseconds added. The original DatumVrijeme object remains unchanged.

ƒ plusNanoSekundi (nanoseconds: broj) : objekat
var v = DatumVrijeme(11, 10, 2023, 15, 22, 33);

var nv = v.plusNanoSekundi(23);
ispis(nv.nanosekunde);
23

minusNanoSekundi

The minusNanoSekundi function returns a copy of the calling DatumVrijeme object with the specified number of nanoseconds subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusNanoSekundi (nanoseconds: broj) : objekat
var v = DatumVrijeme(11, 10, 2023, 15, 22, 00);

var nv = v.minusNanoSekundi(22);
ispis(nv.nanosekunde);
38

plusDana

The plusDana function returns a copy of the calling DatumVrijeme object with the specified number of days added. The original DatumVrijeme object remains unchanged.

ƒ plusDana (days: broj) : objekat
var date = DatumVrijeme(11, 10, 2023, 11,10,2000, 12, 15);

var nd = date.plusDana(10);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
21.10.2000

minusDana

The minusDana function returns a copy of the calling DatumVrijeme object with the specified number of days subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusDana (days: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.minusDana(10);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
1.10.2000

plusSedmica

The plusSedmica function returns a copy of the calling DatumVrijeme object with the specified number of weeks added. The original DatumVrijeme object remains unchanged.

ƒ plusSedmica (weeks: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.plusSedmica(2);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
25.10.2000

minusSedmica

The minusSedmica function returns a copy of the calling DatumVrijeme object with the specified number of weeks subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusSedmica (weeks: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.minusSedmica(1);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
4.10.2000

plusMjeseci

The plusMjeseci function returns a copy of the calling DatumVrijeme object with the specified number of months added. The original DatumVrijeme object remains unchanged.

ƒ plusMjeseci (months: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.plusMjeseci(2);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
11.12.2000

minusMjeseci

The minusMjeseci function returns a copy of the calling DatumVrijeme object with the specified number of months added. The original DatumVrijeme object remains unchanged.

ƒ minusMjeseci (months: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.minusMjeseci(2);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
11.8.2000

plusGodina

The plusGodina function returns a copy of the calling DatumVrijeme object with the specified number of years added. The original DatumVrijeme object remains unchanged.

ƒ plusGodina (years: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.plusGodina(23);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
11.10.2023

minusGodina

The minusGodina function returns a copy of the calling DatumVrijeme object with the specified number of years subtracted. The original DatumVrijeme object remains unchanged.

ƒ minusGodina (years: broj) : objekat
var date = DatumVrijeme(11,10,2000, 12, 15);

var nd = date.minusGodina(20);
ispis(date.danMjeseca, ".", date.mjesec, ".", date.godina);
11.10.1980

periodIzmedju

The periodIzmedju function determines how much time has passed between the calling DatumVrijeme object and the provided other DatumVrijeme object.

ƒ periodIzmedju (other: objekat) : objekat
var d1 = DatumVrijeme(11, 10, 2000, 12, 15);
var d2 = DatumVrijeme(14, 1, 2003, 12, 15);

ispis(d1.periodIzmedju(d2));
Output:

{ godine: 2, mjeseci: 3, dani: 3 }

jePoslije

The jePoslije function determines whether the calling DatumVrijeme object is after the provided other DatumVrijeme object.

ƒ jePoslije (other: objekat) : logički
var d1 = DatumVrijeme(11, 10, 2000, 12, 15);
var d2 = DatumVrijeme(14, 1, 2003, 12, 15);

ispis(d1.jePoslije(d2));
ispis(d2.jePoslije(d1));
Output:

netačno
tačno

jePrije

The jePrije function determines whether the calling DatumVrijeme object is before the provided other DatumVrijeme object.

ƒ jePrije (other: objekat) : logički
var d1 = DatumVrijeme(11, 10, 2000, 12, 15);
var d2 = DatumVrijeme(14, 1, 2003, 12, 15);

ispis(d1.jePrije(d2));
ispis(d2.jePrije(d1));
Output:

tačno
netačno

jednako

The jednako function determines whether the calling DatumVrijeme object is equal to the provided other DatumVrijeme object.

ƒ jednako (other: objekat) : logički
var t1 = DatumVrijeme(11, 10, 2000, 12, 15);
var t2 = DatumVrijeme(11, 10, 2023, 12, 15);

var t3 = DatumVrijeme(14, 1, 2003, 12, 15);
var t4 = DatumVrijeme(14, 1, 2003, 12, 15);

ispis(t1.jednako(t2));
ispis(t3.jednako(t4));
Output:

netačno
tačno