From Test-Scratch-Wiki

Days Since 2000
Days since 2000.png
Category Sensing
Type Reporter
Introduced in 2.0

The Days Since 2000 block is a Sensing block and a reporter block. It reports the amount of days (and fractions of a day) since 00:00:00 1 January 2000 (UTC), and is a replacement of the Scratch Days block, which never made the official release of 2.0.

It is one of the two date/time blocks in Scratch. The other is current (), which reports the date or time. Both these blocks can be worked in unison with one another for a variety of time-related scripts and projects.

Example Uses

This block can be used in some of the following ways:

  • Making a countdown
say (join ((9132) - (days since 2000)) [ days till 2025!])
  • Making something unavailable before or after a certain date
if <(days since 2000) < (5479)> then
  change [money v] by [1000]
else
  say [This feature is unavailable after 2015.]
end
  • Corresponding real-life events with projects
define mark (event) for (value) days from now
add ((days since 2000) + (value)) to [eventDates v]
add (event) to [eventNames v]

define search calendar for (event)
set [i v] to (0)
repeat until <<(i) > (length of [eventNames v])> or <(item (i) of [eventNames v]) = (event)>>
change [i v] by (1)
end
if <(i) > (length of [eventNames v])> then
set [output v] to (join (join [Your search for ] (event)) [ was not found.])
else
if <(days since 2000) < (item (i) of [eventDates v])> then
set [output v] to (join (join (join (join [Your event ] (event)) [ is in ]) ((item (i) of [eventDates v]) - (days since 2000))) [ days])
else
if <(days since 2000) = (item (i) of [eventDates v])>
set [output v] to (join (event) [ is today!])
else
set [output v] to (join (join [This event happened ] ((days since 2000) - (item (i) of [eventDates v]))) [ days ago.])
end
end
end

Workaround

Main article: List of Block Workarounds

Where d = days since 2000:

set [d v] to ((((367) * (year)) - ([floor v] of (((7) * ((year) + ([floor v] of (((month) + (9)) / (12))))) / (4)))) + ((([floor v] of (((275) * (month)) / (9))) + (day)) - (730530)))
if <(d) < [-36435]> then
    change [d v] by (1)
end
if <(d) < [-72990]> then
    change [d v] by (1)
end
if <(d) > [36585]> then
    change [d v] by (-1)
end
change [d v] by (-1)

Correct from 1800-2199.

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.