Documentation
¶
Overview ¶
The time packages enable parsing, and working with times and durations.
var lib = require('time'); var res = lib.detect("See you on Sunday", time.now()); console.log(res);
Index ¶
- func New(orb *orbit.Orbit) interface{}
- type Duration
- func (this *Duration) Debug() string
- func (this *Duration) Hours() float64
- func (this *Duration) MarshalBinary() ([]byte, error)
- func (this *Duration) MarshalText() ([]byte, error)
- func (this *Duration) Minutes() float64
- func (this *Duration) Nanoseconds() int64
- func (this *Duration) Seconds() float64
- func (this *Duration) String() string
- type Module
- func (this *Module) After(after int, call otto.Value, args ...interface{}) *timer
- func (this *Module) Detect(text string, base *Time) *Time
- func (this *Module) Duration(text string) *Duration
- func (this *Module) Every(every int, call otto.Value, args ...interface{}) *timer
- func (this *Module) Now() *Time
- func (this *Module) Parse(text, format string) *Time
- func (this *Module) Since(val *Time) *Duration
- func (this *Module) Sleep(millis int)
- func (this *Module) Unix(sec, nsec int64) *Time
- func (this *Module) Until(val *Time) *Duration
- type Time
- func (this *Time) After(other *Time) bool
- func (this *Time) Before(other *Time) bool
- func (this *Time) Day() int
- func (this *Time) Debug() string
- func (this *Time) Equal(other *Time) bool
- func (this *Time) Hour() int
- func (this *Time) MarshalBinary() ([]byte, error)
- func (this *Time) MarshalText() ([]byte, error)
- func (this *Time) Minute() int
- func (this *Time) Month() time.Month
- func (this *Time) Nanosecond() int
- func (this *Time) Second() int
- func (this *Time) Since(other *Time) *Duration
- func (this *Time) String() string
- func (this *Time) Unix() int64
- func (this *Time) UnixNano() int64
- func (this *Time) Until(other *Time) *Duration
- func (this *Time) Year() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Duration ¶
func (*Duration) MarshalBinary ¶
func (*Duration) MarshalText ¶
func (*Duration) Nanoseconds ¶
type Module ¶
type Module struct { RFC822 string RFC822Z string RFC850 string RFC1123 string RFC1123Z string RFC3339 string RFC3339N string KITCHEN string // contains filtered or unexported fields }
func (*Module) After ¶
Every schedules the execution of a callback function after the specified number of milliseconds.
var time = require('time'); time.after(1000, function() { console.log("Hi there!") })
To pass arguments to the callback function, pass them in as subsequent arguments to the function.
var time = require('time'); time.every(1000, function() { console.log(arguments); }, 1, 2, "three")
func (*Module) Detect ¶
Detect detects a date or time within a piece of text using natural language processing, and returns a time object, relative to the `base` time argument.
var time = require('time'); var when = time.Detect("Call me next wednesday at 2:25 p.m", time.Now())
func (*Module) Duration ¶
Duration detects a time duration parsed from a string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
var time = require('time'); var duration = time.Duration("300ms")
func (*Module) Every ¶
Every schedules repeated execution of a callback function after the specified number of milliseconds.
var time = require('time'); time.every(1000, function() { console.log("Hi there!") })
To pass arguments to the callback function, pass them in as subsequent arguments to the function.
var time = require('time'); time.every(1000, function() { console.log(arguments); }, 1, 2, "three")
func (*Module) Parse ¶
Parse parses a formatted string and returns the time value it represents. The format defines which input format should be used to parse the string.
var time = require('time'); var when = time.Parse("2016-22-04T15:04:05Z07:00", time.RFC3339)