Library

Video Player is loading.
 
Current Time 0:00
Duration 4:47
Loaded: 0%
 

x1.00


Back

Games & Quizzes

Training Mode - Typing
Fill the gaps to the Lyric - Best method
Training Mode - Picking
Pick the correct word to fill in the gap
Fill In The Blank
Find the missing words in a sentence Requires 5 vocabulary annotations
Vocabulary Match
Match the words to the definitions Requires 10 vocabulary annotations

You may need to watch a part of the video to unlock quizzes

Don't forget to Sign In to save your points

Challenge Accomplished

PERFECT HITS +NaN
HITS +NaN
LONGEST STREAK +NaN
TOTAL +
- //

We couldn't find definitions for the word you were looking for.
Or maybe the current language is not supported

  • 00:06

    hi there serdar yagulp here for infoworld in this  episode of smart go we're going to take a closer  
    hi there serdar yagulp here for infoworld in this  episode of smart go we're going to take a closer  

  • 00:11

    look at the way go handles date and time values  by way of the time module the time module and go  
    look at the way go handles date and time values  by way of the time module the time module and go  

  • 00:18

    gives us access to objects and methods that let us  get the current time create time and date values  
    gives us access to objects and methods that let us  get the current time create time and date values  

  • 00:23

    from scratch and perform formatting on existing  time values it also gives us tools for working  
    from scratch and perform formatting on existing  time values it also gives us tools for working  

  • 00:29

    with time zones easily one of the least favorite  aspects of dealing with date and time values if  
    with time zones easily one of the least favorite  aspects of dealing with date and time values if  

  • 00:33

    you're a programmer but the time module helps  handle those things in a straightforward way  
    you're a programmer but the time module helps  handle those things in a straightforward way  

  • 00:39

    let's start with a simple example getting the  current time and printing it to the console here  
    let's start with a simple example getting the  current time and printing it to the console here  

  • 00:45

    first we import the time module and then we use  the time.now method to get the current time and  
    first we import the time module and then we use  the time.now method to get the current time and  

  • 00:50

    date from the system and store it in the variable  t now if we print this to the console like this  
    date from the system and store it in the variable  t now if we print this to the console like this  

  • 00:56

    we're going to get a very complex and detailed  output this includes the date the time the time  
    we're going to get a very complex and detailed  output this includes the date the time the time  

  • 01:03

    zone and some additional information about the  current processes monotonic clock that's something  
    zone and some additional information about the  current processes monotonic clock that's something  

  • 01:09

    that's used to measure elapsed time between events  inside a process instead of the absolute time of  
    that's used to measure elapsed time between events  inside a process instead of the absolute time of  

  • 01:13

    the system at large that's something worth going  into detail about in its own video though so for  
    the system at large that's something worth going  into detail about in its own video though so for  

  • 01:17

    now we'll leave it alone now if we just want  to print a few details about the current date  
    now we'll leave it alone now if we just want  to print a few details about the current date  

  • 01:23

    and time instead of the whole thing we could use  the format method of the time object to do this  
    and time instead of the whole thing we could use  the format method of the time object to do this  

  • 01:29

    with format we pass along a special formatting  code which looks a little bit like a date and time  
    with format we pass along a special formatting  code which looks a little bit like a date and time  

  • 01:35

    but is actually a way to indicate how to  format specific components of the date and time  
    but is actually a way to indicate how to  format specific components of the date and time  

  • 01:40

    for instance in in the format string we have this  code 2006 that's actually an indication we want  
    for instance in in the format string we have this  code 2006 that's actually an indication we want  

  • 01:46

    to insert a four digit year so when we run this  code we will see only a few parts of the date and  
    to insert a four digit year so when we run this  code we will see only a few parts of the date and  

  • 01:53

    time the ones that we most need now let's say i  want to create a time and date value from scratch  
    time the ones that we most need now let's say i  want to create a time and date value from scratch  

  • 02:00

    not just by sampling the system time and to  do this we can use the date method to create  
    not just by sampling the system time and to  do this we can use the date method to create  

  • 02:06

    a time.time object by supplying it with  the needed details about our time and date  
    a time.time object by supplying it with  the needed details about our time and date  

  • 02:11

    here in this example i've got a struct named  movie which has two fields one is the name of  
    here in this example i've got a struct named  movie which has two fields one is the name of  

  • 02:16

    a movie a string and the other is its release  date expressed as a time.time object now when  
    a movie a string and the other is its release  date expressed as a time.time object now when  

  • 02:22

    i create an instance of this struct and i want  to populate the release field i make a call to  
    i create an instance of this struct and i want  to populate the release field i make a call to  

  • 02:26

    time.date and i pass along in this order the  year the month the day and then the hour minute  
    time.date and i pass along in this order the  year the month the day and then the hour minute  

  • 02:34

    second and millisecond of the time in question  and then finally a time zone reference for now  
    second and millisecond of the time in question  and then finally a time zone reference for now  

  • 02:39

    i'm going to use utc as the time zone but we'll  go into detail later about how we can alter that  
    i'm going to use utc as the time zone but we'll  go into detail later about how we can alter that  

  • 02:45

    now you notice for this structure that i  am using a format function and in there it  
    now you notice for this structure that i  am using a format function and in there it  

  • 02:50

    converts the time object to a simple date when  we print out the whole movie struct as a string  
    converts the time object to a simple date when  we print out the whole movie struct as a string  

  • 02:56

    if we run this you can see that's what happens we  don't need to know the the actual time the movie  
    if we run this you can see that's what happens we  don't need to know the the actual time the movie  

  • 03:01

    was released just the day and date now if we want  to provide adjustments for time zones we can use  
    was released just the day and date now if we want  to provide adjustments for time zones we can use  

  • 03:08

    the time dot load location method to create a  time adjustment object for specific time zone  
    the time dot load location method to create a  time adjustment object for specific time zone  

  • 03:14

    and then we pass that to the dot in method on a  time object to adjust it here in this reworked  
    and then we pass that to the dot in method on a  time object to adjust it here in this reworked  

  • 03:22

    version of the earlier example i showed you i'm  getting the current time which is pre-adjusted  
    version of the earlier example i showed you i'm  getting the current time which is pre-adjusted  

  • 03:27

    by the way for utc minus five by way of my system  clock that's because i'm on the east coast of the  
    by the way for utc minus five by way of my system  clock that's because i'm on the east coast of the  

  • 03:32

    united states and if i want to render this as just  utc i get a utc adjustment object i'll call it tz  
    united states and if i want to render this as just  utc i get a utc adjustment object i'll call it tz  

  • 03:40

    and i pass that to n and i can do the same thing  if i want to get the time from the west coast  
    and i pass that to n and i can do the same thing  if i want to get the time from the west coast  

  • 03:46

    so when i run this program i will get three  time outputs one is for my original time zone  
    so when i run this program i will get three  time outputs one is for my original time zone  

  • 03:51

    one is for utc and one is  for my friends in california  
    one is for utc and one is  for my friends in california  

  • 03:56

    so to sum up time objects and go let you sample  the current time or create a new time object from  
    so to sum up time objects and go let you sample  the current time or create a new time object from  

  • 04:02

    scratch that lets you render time to strings using  the format method and they let you apply time zone  
    scratch that lets you render time to strings using  the format method and they let you apply time zone  

  • 04:08

    adjustments to existing times and in future videos  i'm going to show you how you could perform more  
    adjustments to existing times and in future videos  i'm going to show you how you could perform more  

  • 04:14

    sophisticated operations with times and dates  for instance performing math on times and dates  
    sophisticated operations with times and dates  for instance performing math on times and dates  

  • 04:18

    or using time intervals in your programs  to do something on a regular basis or to  
    or using time intervals in your programs  to do something on a regular basis or to  

  • 04:23

    determine how long specific operations take within  a program that's it for this video if you liked it  
    determine how long specific operations take within  a program that's it for this video if you liked it  

  • 04:29

    please leave a comment below and don't forget to  subscribe to the tech talk channel on youtube and  
    please leave a comment below and don't forget to  subscribe to the tech talk channel on youtube and  

  • 04:34

    for more smart go and more dev with serdar be sure  to follow me on facebook youtube and infowold.com
    for more smart go and more dev with serdar be sure  to follow me on facebook youtube and infowold.com

  • 04:46

    you
    you

All

The basics of dates and times in Go

478 views

Video Language:

  • English

Caption Language:

  • English (en)

Accent:

  • English (US)

Speech Time:

92%
  • 4:24 / 4:46

Speech Rate:

  • 201 wpm - Fast

Category:

  • Science & Technology

Intro:

hi there serdar yagulp here for infoworld in this  episode of smart go we're going to take a closer  
look at the way go handles date and time values  by way of the time module the time module and go  
gives us access to objects and methods that let us  get the current time create time and date values  
from scratch and perform formatting on existing  time values it also gives us tools for working  
with time zones easily one of the least favorite  aspects of dealing with date and time values if  
you're a programmer but the time module helps  handle those things in a straightforward way  
let's start with a simple example getting the  current time and printing it to the console here  
first we import the time module and then we use  the time.now method to get the current time and  
date from the system and store it in the variable  t now if we print this to the console like this  
we're going to get a very complex and detailed  output this includes the date the time the time  
zone and some additional information about the  current processes monotonic clock that's something  
that's used to measure elapsed time between events  inside a process instead of the absolute time of  
the system at large that's something worth going  into detail about in its own video though so for  
now we'll leave it alone now if we just want  to print a few details about the current date  
and time instead of the whole thing we could use  the format method of the time object to do this  
with format we pass along a special formatting  code which looks a little bit like a date and time  
but is actually a way to indicate how to  format specific components of the date and time  
for instance in in the format string we have this  code 2006 that's actually an indication we want  
to insert a four digit year so when we run this  code we will see only a few parts of the date and  
time the ones that we most need now let's say i  want to create a time and date value from scratch  

Video Vocabulary

/ˈspeSHəl/

adjective noun

better, greater, or otherwise different from what is usual. thing.

/ˈprōˌɡramər/

noun

person who writes computer programs.

/ˌstrātˈfôrwərd/

adjective

uncomplicated and easy to do or understand.

/inˈklo͞od/

verb

comprise or contain as part of whole.

/inˈsted/

adverb

as alternative or substitute.

verb

To make someone feel better in times of distress.

noun other verb

material thing. Some things you can see or touch, but is not alive. express disagreement.

/ˈaspekt/

noun other verb

part or feature. Elements, features, or qualities of something. form aspect with.

/ˈfôrˌmat/

verb

To set the appearance of a text in a certain way.

adjective noun verb

Not being simple; having many parts or aspects. group of buildings or facilities. cause to form complex.

/ˈsamp(ə)liNG/

noun verb

taking of sample or samples. To try (e.g. food), to see if you like it.

/rəˈlēs/

noun verb

Act of freeing someone from a duty or burden. To allow to leave a jail, cage, etc.; let out.

/ˈabsəˌlo͞ot/

adjective noun

Complete; total; pure; not limited in any way. value or principle.

/kəmˈpōnənt/

noun other

part or element of larger whole. Parts that some things are made up of.