Join Kevin Skoglund for an in-depth discussion in this video DateTime, part of Ruby: Classes and Modules.
- [Instructor] In this movie,…we're going to learn about the Ruby class for DateTime.…Just like the Date class that we saw in the last movie,…the DateTime class is part of the Ruby Standard Library.…That means it's included with Ruby…but it's not automatically loaded unless we ask for it.…DateTime is actually a subclass of Date…and inherits all the behaviors of Date…and it extends them with attributes…and methods about the time.…The way that we get the DateTime class…is not by requiring DateTime,…but just by requiring Date.…
That loads in the standard Ruby library…that includes both Date and DateTime together.…So don't get tripped up by that.…It's not called DateTime.…The library is called Date.…If you load that in, you'll get both.…Date has some pretty standard methods to it,…things that should be familiar to you by now.…DateTime.now returns the current DateTime.…DateTime.new allows us to create one…at a specific date and time.…If we take a DateTime instance…and we call to_time on it,…it converts it into a time instance,…
- Defining a custom class
- Working with instances of a class
- Class and instance attributes and methods
- Class inheritance
- Working with dates and times
- Using modules as namespaces and mixins
- Raising and handling exceptions
Skill Level Beginner
2. Class Attributes and Methods
4. Dates and Times
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.