# Interface: TimeHandlerInterface (/nqtr/index/interfaces/TimeHandlerInterface)



Defined in: [src/interface/TimeHandlerInterface.ts:7](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L7)

Handler that manages the time of the game: the current time and date, the day/week structure
and the time slots.

## Properties [#properties]

### currentDayName [#currentdayname]

\> `readonly` **currentDayName**: `string`

Defined in: [src/interface/TimeHandlerInterface.ts:78](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L78)

The current week day name. If the week days names are not defined, then it will return an empty string.
For example, if the week days names are \['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.

#### Default [#default]

```ts
""
```

***

### currentTimeSlot [#currenttimeslot]

\> `readonly` **currentTimeSlot**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:93](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L93)

The index of the current time slot in [timeSlots](#timeslots).
You can use this property to create "Image that changes based on the time period":

#### Example [#example]

```tsx
import { timeTracker } from '@drincs/nqtr';

function changeBackground() {
    return (
        <img src={`background-${timeTracker.currentTimeSlot}.png`} />
    )
}
```

***

### currentWeekDayNumber [#currentweekdaynumber]

\> `readonly` **currentWeekDayNumber**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:72](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L72)

The current week day number (from: 1 - to: [weekLength](#weeklength)).
For example, if the week length is 7 and the current day is 10, then the result will be 4.

***

### dayEndTime [#dayendtime]

\> `readonly` **dayEndTime**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:20](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L20)

The time at which a day ends. When the time reaches it, the date increases.

***

### dayStartTime [#daystarttime]

\> `readonly` **dayStartTime**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:16](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L16)

The time at which a day starts.

***

### defaultTimeSpent [#defaulttimespent]

\> `readonly` **defaultTimeSpent**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:24](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L24)

The default time spent by [increaseTime](#increasetime) when no delta is given.

***

### getDayName [#getdayname]

\> `readonly` **getDayName**: ((`weekDayNumber`) => `string`) | `undefined`

Defined in: [src/interface/TimeHandlerInterface.ts:49](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L49)

Week days name

#### Param [#param]

**weekDayNumber**

The current week day number (from: 0 - to: [weekLength](#weeklength) - 1).

#### Returns [#returns]

The name of the week day.

#### Example [#example-1]

```ts
(weekDayNumber: number) => {
    const weekDaysNames = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
    return weekDaysNames[weekDayNumber];
}
```

***

### isWeekend [#isweekend]

\> `readonly` **isWeekend**: `boolean`

Defined in: [src/interface/TimeHandlerInterface.ts:67](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L67)

If the current day is greater than or equal to the weekend start day, then it will return true.

***

### timeSlots [#timeslots]

\> `readonly` **timeSlots**: [`ITimeStlot`](/nqtr/index/type-aliases/ITimeStlot)\[]

Defined in: [src/interface/TimeHandlerInterface.ts:28](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L28)

The time slots of a day (e.g. morning, afternoon, evening).

***

### weekendStartDay [#weekendstartday]

\> `readonly` **weekendStartDay**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:36](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L36)

The week day (starting from 0) from which the weekend starts.

***

### weekLength [#weeklength]

\> `readonly` **weekLength**: `number`

Defined in: [src/interface/TimeHandlerInterface.ts:32](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L32)

The number of days in a week.

## Accessors [#accessors]

### currentDate [#currentdate]

#### Get Signature [#get-signature]

\> **get** **currentDate**(): `number`

Defined in: [src/interface/TimeHandlerInterface.ts:62](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L62)

The current date. Date is a numeric variable used to determine and manage the number of days passed.
It's recommended to use currentDate as if it were the current day.
Setting it to `undefined` resets it to 0.

##### Returns [#returns-1]

`number`

#### Set Signature [#set-signature]

\> **set** **currentDate**(`value`): `void`

Defined in: [src/interface/TimeHandlerInterface.ts:63](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L63)

##### Parameters [#parameters]

###### value [#value]

`number` | `undefined`

##### Returns [#returns-2]

`void`

***

### currentTime [#currenttime]

#### Get Signature [#get-signature-1]

\> **get** **currentTime**(): `number`

Defined in: [src/interface/TimeHandlerInterface.ts:55](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L55)

The current time. Time is a numeric variable used to determine and manage time during a day/date.
It's recommended to use currentTime as if it were the current time. If you also want to manage minutes, you can use a float value.
Setting it to `undefined` resets it to [dayStartTime](#daystarttime).

##### Returns [#returns-3]

`number`

#### Set Signature [#set-signature-1]

\> **set** **currentTime**(`value`): `void`

Defined in: [src/interface/TimeHandlerInterface.ts:56](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L56)

##### Parameters [#parameters-1]

###### value [#value-1]

`number` | `undefined`

##### Returns [#returns-4]

`void`

## Methods [#methods]

### increaseDate() [#increasedate]

\> **increaseDate**(`delta?`, `time?`): `number`

Defined in: [src/interface/TimeHandlerInterface.ts:107](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L107)

Increase the current date by the given delta.

#### Parameters [#parameters-2]

##### delta? [#delta]

`number`

The number of days to increase (default: 1).

##### time? [#time]

`number`

The time of the new day (default: [dayStartTime](#daystarttime)).

#### Returns [#returns-5]

`number`

The new current date.

***

### increaseTime() [#increasetime]

\> **increaseTime**(`delta?`): `number`

Defined in: [src/interface/TimeHandlerInterface.ts:100](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L100)

Increase the current time by the given time spent.
If the new time is greater than or equal to [dayEndTime](#dayendtime), then it will increase the day and set the new time.

#### Parameters [#parameters-3]

##### delta? [#delta-1]

`number`

The time spent (default: [defaultTimeSpent](#defaulttimespent)).

#### Returns [#returns-6]

`number`

The new current time.

***

### initialize() [#initialize]

\> **initialize**(`settings`): `void`

Defined in: [src/interface/TimeHandlerInterface.ts:12](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L12)

Set the time settings. Omitted values fall back to their defaults.

#### Parameters [#parameters-4]

##### settings [#settings]

[`TimeSettings`](/nqtr/index/type-aliases/TimeSettings)

The time settings.

#### Returns [#returns-7]

`void`

***

### nowIsBetween() [#nowisbetween]

\> **nowIsBetween**(`fromTime`, `toTime`): `boolean`

Defined in: [src/interface/TimeHandlerInterface.ts:114](https://github.com/DRincs-Productions/nqtr/blob/2a388160e173dbee4577b96ebd63be923d890899/src/interface/TimeHandlerInterface.ts#L114)

Check if the current time is between the given times.

#### Parameters [#parameters-5]

##### fromTime [#fromtime]

`number` | `undefined`

The starting time. If the [currentTime](#currenttime) is equal to this time, the function will return true. If undefined, the day start is used.

##### toTime [#totime]

`number` | `undefined`

The ending time. If undefined, the day end is used.

#### Returns [#returns-8]

`boolean`

true if the current time is between the given times, otherwise false.
