Package org.openpatch.scratch
Class Clock
java.lang.Object
org.openpatch.scratch.Clock
The date and time of the computer the program runs on, the same values
Scratch's "current [year]" and "days since 2000" blocks report.
Example usage:
this.setDirection(Clock.getSecond() * 6);
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgetDay()Returns the current day of the month, from 1 to 31.static intReturns the current day of the week, from 1 for Monday to 7 for Sunday.static intReturns the number of days that have passed since the first of January 2000.static intgetHour()Returns the current hour, from 0 to 23.static intReturns the milliseconds of the current second, from 0 to 999.static intReturns the current minute, from 0 to 59.static intgetMonth()Returns the current month, from 1 for January to 12 for December.static intReturns the current second, from 0 to 59.static intgetYear()Returns the current year, for example 2026.
-
Method Details
-
getYear
public static int getYear()Returns the current year, for example 2026.- Returns:
- the year
- Scratch Block:
- (current [year v])
-
getMonth
public static int getMonth()Returns the current month, from 1 for January to 12 for December.- Returns:
- the month
- Scratch Block:
- (current [month v])
-
getDay
public static int getDay()Returns the current day of the month, from 1 to 31.- Returns:
- the day of the month
- Scratch Block:
- (current [date v])
-
getDayOfWeek
public static int getDayOfWeek()Returns the current day of the week, from 1 for Monday to 7 for Sunday.- Returns:
- the day of the week
- Scratch Block:
- (current [day of week v])
-
getHour
public static int getHour()Returns the current hour, from 0 to 23.- Returns:
- the hour
- Scratch Block:
- (current [hour v])
-
getMinute
public static int getMinute()Returns the current minute, from 0 to 59.- Returns:
- the minute
- Scratch Block:
- (current [minute v])
-
getSecond
public static int getSecond()Returns the current second, from 0 to 59.- Returns:
- the second
- Scratch Block:
- (current [second v])
-
getMillisecond
public static int getMillisecond()Returns the milliseconds of the current second, from 0 to 999.- Returns:
- the millisecond
-
getDaysSince2000
public static int getDaysSince2000()Returns the number of days that have passed since the first of January 2000.- Returns:
- the days since 2000
- Scratch Block:
- (days since 2000)
-