dow

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 3 Imported by: 0

README

dow (Day Of Week)

Display day of week for specified date.

Install

CLI Tool

go install github.com/umi-uyura/dow/cmd/dow@latest

Library

go get github.com/umi-uyura/dow

Usage

CLI Tool
dow [options] [date]
  • Support date format
    • yyyy-mm-dd
    • yyyy/mm/dd
    • yyyy.mm.dd
  • When execute without arguments, display current day of week.
  • Display day of week in language of locale, set LANG environment variable.

Options

  • -w Outputs the name of the day of the week along with the date
  • -s <separator> Specifies the date separator
Example
$ dow 2023-1-1
Sun

$ dow -w 2023-1-2
2023-1-2(Mon)

$ dow -w -s / 2023-1-3
2023/1/3(Tue)

$ LANG=ja_JP dow 2023/1/4
水

$ LANG=zh_CN dow 2023.1.5
四
Library

See: dow package - github.com/umi-uyura/dow - Go Packages

License

MIT License

Documentation

Overview

Dow package provide functions to get the name of the day of the week.

The locales supported by this package depend on github.com/goodsign/monday. https://pkg.go.dev/github.com/goodsign/monday#pkg-constants

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocaleName

func GetLocaleName(date time.Time, lang string) string

Get the locale name of the day of the week for a given date

If the specified locale is not supported, returns the name of the day of the week in the en_US locale.

Example
package main

import (
	"fmt"
	"time"

	"github.com/umi-uyura/dow"
)

func main() {
	d, _ := time.Parse("2006-1-2", "2023-1-1")
	weekday := dow.GetLocaleName(d, "ja_JP")
	fmt.Println(weekday)
}
Output:

func GetLocaleNameWithDate

func GetLocaleNameWithDate(date time.Time, lang string) string

Get the locale name of the day of the week for a given date with the date

If the specified locale is not supported, returns the name of the day of the week in the en_US locale.

Example
package main

import (
	"fmt"
	"time"

	"github.com/umi-uyura/dow"
)

func main() {
	d, _ := time.Parse("2006-1-2", "2023-1-1")
	weekday := dow.GetLocaleNameWithDate(d, "ja_JP")
	fmt.Println(weekday)
}
Output:
2023-1-1(日)

func GetName

func GetName(date time.Time) string

Get the name of the day of the week for a given date.

Return the name of the day of the week in en_US locale.

Example
package main

import (
	"fmt"
	"time"

	"github.com/umi-uyura/dow"
)

func main() {
	d, _ := time.Parse("2006-1-2", "2023-1-1")
	weekday := dow.GetName(d)
	fmt.Println(weekday)
}
Output:
Sun

func GetNameWithDate

func GetNameWithDate(date time.Time) string

Get the name of the day of the week for a given date with the date.

Return the name of the day of the week in en_US locale.

Example
package main

import (
	"fmt"
	"time"

	"github.com/umi-uyura/dow"
)

func main() {
	d, _ := time.Parse("2006-1-2", "2023-1-1")
	weekday := dow.GetNameWithDate(d)
	fmt.Println(weekday)
}
Output:
2023-1-1(Sun)

Types

This section is empty.

Directories

Path Synopsis
cmd
dow command

Jump to

Keyboard shortcuts

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