time

package
v0.0.0-...-c5bcced Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(orb *orbit.Orbit) interface{}

Types

type Duration

type Duration struct {
	Val time.Duration `console:"-"`
	// contains filtered or unexported fields
}

func NewDuration

func NewDuration(orb *orbit.Orbit, val time.Duration) *Duration

func (*Duration) Debug

func (this *Duration) Debug() string

func (*Duration) Hours

func (this *Duration) Hours() float64

func (*Duration) MarshalBinary

func (this *Duration) MarshalBinary() ([]byte, error)

func (*Duration) MarshalText

func (this *Duration) MarshalText() ([]byte, error)

func (*Duration) Minutes

func (this *Duration) Minutes() float64

func (*Duration) Nanoseconds

func (this *Duration) Nanoseconds() int64

func (*Duration) Seconds

func (this *Duration) Seconds() float64

func (*Duration) String

func (this *Duration) String() string

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

func (this *Module) After(after int, call otto.Value, args ...interface{}) *timer

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

func (this *Module) Detect(text string, base *Time) *Time

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

func (this *Module) Duration(text string) *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

func (this *Module) Every(every int, call otto.Value, args ...interface{}) *timer

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) Now

func (this *Module) Now() *Time

func (*Module) Parse

func (this *Module) Parse(text, format string) *Time

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)

func (*Module) Since

func (this *Module) Since(val *Time) *Duration

func (*Module) Sleep

func (this *Module) Sleep(millis int)

Sleep pauses the execution of the current code for the specified number of milliseconds.

var time = require('time');
time.Sleep(3000);
console.log("Finally here");

func (*Module) Unix

func (this *Module) Unix(sec, nsec int64) *Time

func (*Module) Until

func (this *Module) Until(val *Time) *Duration

type Time

type Time struct {
	Val time.Time `console:"-"`
	// contains filtered or unexported fields
}

func NewTime

func NewTime(orb *orbit.Orbit, val time.Time) *Time

func (*Time) After

func (this *Time) After(other *Time) bool

func (*Time) Before

func (this *Time) Before(other *Time) bool

func (*Time) Day

func (this *Time) Day() int

func (*Time) Debug

func (this *Time) Debug() string

func (*Time) Equal

func (this *Time) Equal(other *Time) bool

func (*Time) Hour

func (this *Time) Hour() int

func (*Time) MarshalBinary

func (this *Time) MarshalBinary() ([]byte, error)

func (*Time) MarshalText

func (this *Time) MarshalText() ([]byte, error)

func (*Time) Minute

func (this *Time) Minute() int

func (*Time) Month

func (this *Time) Month() time.Month

func (*Time) Nanosecond

func (this *Time) Nanosecond() int

func (*Time) Second

func (this *Time) Second() int

func (*Time) Since

func (this *Time) Since(other *Time) *Duration

func (*Time) String

func (this *Time) String() string

func (*Time) Unix

func (this *Time) Unix() int64

func (*Time) UnixNano

func (this *Time) UnixNano() int64

func (*Time) Until

func (this *Time) Until(other *Time) *Duration

func (*Time) Year

func (this *Time) Year() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL