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
- takes: no parameters
- returns:
DatumVrijeme
object representing the current time
- special cases: none
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
- takes: str -
tekst
to parse - returns:
DatumVrijeme
object parsed fromstr
- special cases:
- Throws exception if
str
cannot be parsed
- Throws exception if
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
- takes:
- str -
tekst
to parse - format -
tekst
representing format to parse by
- str -
- returns:
DatumVrijeme
object parsed fromstr
- special cases:
- Throws exception if
str
cannot be parsed - Throws exception if
format
is not a valid time format
- Throws exception if
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
- takes:
- day -
broj
between 1 and 31 - month -
broj
between 1 and 12 - year -
broj
between -999999999 and 999999999 - hour -
broj
between 0 and 59 - minute -
broj
between 0 and 59
- day -
- returns:
DatumVrijeme
object according to the provided day, month, year, hour and minute
- special cases:
- Throws exception if
year
,month
,day
,hour
orminute
is an invalid value
- Throws exception if
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
- takes:
- day -
broj
between 1 and 31 - month -
broj
between 1 and 12 - year -
broj
between -999999999 and 999999999 - hours -
broj
between 0 and 59 - minutes -
broj
between 0 and 59 - seconds -
broj
between 0 and 59 - nanoseconds -
broj
between 0 and 999999999
- day -
- returns:
DatumVrijeme
object according to the provided day, month and year
- special cases:
- Throws exception if
year
,month
,day
,hour
,minute
,second
ornanosecond
is an invalid value
- Throws exception if
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
- takes:
- hours - number of hours to add (
broj
)
- hours - number of hours to add (
- returns:
- new
DatumVrijeme
object with the specified number of hours added
- new
- special cases: none
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
- takes:
- hours - number of hours to subtract (
broj
)
- hours - number of hours to subtract (
- returns:
- new
DatumVrijeme
object with the specified number of hours subtracted
- new
- special cases: none
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
- takes:
- minutes - number of minutes to add (
broj
)
- minutes - number of minutes to add (
- returns:
- new
DatumVrijeme
object with the specified number of minutes added
- new
- special cases: none
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
- takes:
- minutes - number of minutes to add (
broj
)
- minutes - number of minutes to add (
- returns:
- new
DatumVrijeme
object with the specified number of minutes subtracted
- new
- special cases: none
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
- takes:
- seconds - number of seconds to add (
broj
)
- seconds - number of seconds to add (
- returns:
- new
DatumVrijeme
object with the specified number of seconds added
- new
- special cases: none
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
- takes:
- seconds - number of seconds to add (
broj
)
- seconds - number of seconds to add (
- returns:
- new
DatumVrijeme
object with the specified number of seconds subtracted
- new
- special cases: none
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
- takes:
- nanoseconds - number of nanoseconds to add (
broj
)
- nanoseconds - number of nanoseconds to add (
- returns:
- new
DatumVrijeme
object with the specified number of nanoseconds added
- new
- special cases: none
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
- takes:
- nanoseconds - number of nanoseconds to add (
broj
)
- nanoseconds - number of nanoseconds to add (
- returns:
- new
DatumVrijeme
object with the specified number of nanoseconds subtracted
- new
- special cases: none
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
- takes:
- days - number of days to add (
broj
)
- days - number of days to add (
- returns:
- new
DatumVrijeme
object with the specified number of days added
- new
- special cases: none
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
- takes:
- days - number of days to subtract (
broj
)
- days - number of days to subtract (
- returns:
- new
DatumVrijeme
object with the specified number of days subtracted
- new
- special cases: none
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
- takes:
- weeks - number of weeks to add (
broj
)
- weeks - number of weeks to add (
- returns:
- new
DatumVrijeme
object with the specified number of weeks added
- new
- special cases: none
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
- takes:
- weeks - number of weeks to subtract (
broj
)
- weeks - number of weeks to subtract (
- returns:
- new
DatumVrijeme
object with the specified number of weeks subtracted
- new
- special cases: none
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
- takes:
- months - number of months to add (
broj
)
- months - number of months to add (
- returns:
- new
DatumVrijeme
object with the specified number of months added
- new
- special cases: none
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
- takes:
- months - number of months to add (
broj
)
- months - number of months to add (
- returns:
- new
DatumVrijeme
object with the specified number of months added
- new
- special cases: none
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
- takes:
- years - number of years to add (
broj
)
- years - number of years to add (
- returns:
- new
DatumVrijeme
object with the specified number of years added
- new
- special cases: none
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
- takes:
- years - number of years to subtract (
broj
)
- years - number of years to subtract (
- returns:
- new
DatumVrijeme
object with the specified number of years subtracted
- new
- special cases: none
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
- takes:
- other -
DatumVrijeme
object
- other -
- returns:
DatumVrijeme
object representing the time passed between callingDatumVrijeme
andother
- special cases: none
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
- takes:
- other -
DatumVrijeme
object
- other -
- returns:
logički
tačno
if the callingDatumVrijeme
object is afterother
netačno
otherwise
- special cases: none
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
- takes:
- other -
DatumVrijeme
object
- other -
- returns:
logički
tačno
if the callingDatumVrijeme
object is beforeother
netačno
otherwise
- special cases: none
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
- takes:
- other -
DatumVrijeme
object
- other -
- returns:
logički
tačno
if the callingDatumVrijeme
object andother
have the same year, month, day, hours, miutes, seconds and nanoseconds valuesnetačno
otherwise
- special cases: none
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