example_test.go 669 B

123456789101112131415161718192021222324252627
  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package currency_test
  5. import (
  6. "fmt"
  7. "time"
  8. "golang.org/x/text/currency"
  9. )
  10. func ExampleQuery() {
  11. t1799, _ := time.Parse("2006-01-02", "1799-01-01")
  12. for it := currency.Query(currency.Date(t1799)); it.Next(); {
  13. from := ""
  14. if t, ok := it.From(); ok {
  15. from = t.Format("2006-01-02")
  16. }
  17. fmt.Printf("%v is used in %v since: %v\n", it.Unit(), it.Region(), from)
  18. }
  19. // Output:
  20. // GBP is used in GB since: 1694-07-27
  21. // GIP is used in GI since: 1713-01-01
  22. // USD is used in US since: 1792-01-01
  23. }