Days Since 2000 (block)

Days Since 2000
2.0 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) < (5845)> then
  change [money v] by [1000]
else
  say [This feature is unavailable after 2016.]
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])> then
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 days = days since 2000:

set [days v] to ((((367) * (current [year v])) - ([floor v] of (((7) * ((current [year v]) + ([floor v] of (((current [month v]) + (9)) / (12))))) / (4)))) + ((([floor v] of (((275) * (current [month v])) / (9))) + (current [date v])) - (730531)))
change [days v] by ((<(days) < [-36435]> + <(days) < [-72990]>) - <(days) > [36585]>)

Correct from 1800-2199.

See Also

  • This page was last modified on 4 July 2017, at 17:19.