Test Blog 2

  Deven Rai
  05 Mar, 2021
 

Test


Cover
index

Pulling a date from a string involves slicing the string into substrings, which are then converted into values for year, month, and day. Last week’s Lesson demonstrated such code. This week, the final step is accomplished, converting year, month, and day

integers into a time_t value.

I can think of two ways to create a time_t value. My default method, which I’ve written about before on this blog, is to populate a tm structure which can then be converted into a time_t value. It’s kind of a backwards way to obtain the value, but I know it works.

As a review, the time_t value represents the Unix epoch, or the number of seconds passed since January 1, 1970. The tm structure contains members that reference individual parts of a date, such as the year, month, day of the month, and so on. Both of time_t and the tm structure are defined in the time.h header file.

In my earlier post, I populated a tm structure with the current time, then updated specific members to reflect the time_t value I wanted. Here’s a snippet from the code:

About Author


Deven Rai
Deven Rai

This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai. This a short description about the blog author Deven Rai.

View All Articles

Comments


No comments yet. Be first to post one.

Add Comment



Drop us a Message

9801131225
Available 24 hours for your meaasge