Join Kevin Skoglund for an in-depth discussion in this video Time, part of Ruby: Classes and Modules.
- In this chapter, we're going to take…a little break from working with the…classes that we've been working with.…And take a look at a couple of specific…built-in classes in Ruby for date and time.…It's very common for you to be able…to use dates and times in our programs.…It's important to learn how to use these classes.…Let's start with time.…In Ruby, all times are stored as…the number of seconds since January 1, 1970.…That's the same thing as Unix time.…That's how Unix defines its time;…it counts the number of seconds since 1970.…And that's how it stores it.…
All the times that it stores also…include a fraction of a second.…That's going to be important when…we're comparing two times.…Two times may look the same but…the fractions of a second may be off.…The simplest way to get back a time…is just to call for time.now.…That's a class method…and turns in time instance.…And it's going to look something like…this as a simple representation.…But it's actually an instance…that we can make instance method calls on.…For example, we can call the to_i method…
- 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?
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.