タグ

dateとGoに関するAutomatorのブックマーク (7)

  • Goのtimeパッケージのリファレンスタイム(2006年1月2日)は何の日? - Qiita

    Goのtimeパッケージのフォーマットは独特だ。普通のUnixのstrftimeとかだとフォーマット文字列は%Yとか%mといった文字列なのだけど、Goの場合はそのかわりにある種の「サンプル文字列」を与えるという仕組みになっている。 たとえば次の文字列はGoでは時刻の正しいフォーマット文字列だ。 %Y(年)の代わりに"2006"、%b(月の名前)の代わりに"Jan"と書くといったルールになっている。"%Y-%m-%d"の代わりに"2006-01-02"と書くのは見た目にわかりやすいといえばわかりやすいが、"2006年1月2日15時04分05秒"以外の時刻は正しいフォーマット文字列としては認識されない。2006の代わりに2007とか書いても意味がない。 では一体この2006年1月2日という特別な日は、なんの日なのか? 最初は1970年1月1日(エポック)から特定の時間が経過した日だとか、あるい

    Goのtimeパッケージのリファレンスタイム(2006年1月2日)は何の日? - Qiita
  • Convert UTC to "local" time in Go

    How can I convert UTC time to local time? I've created a map with the UTC difference for all the countries I need the local time. Then I add that difference as duration to the current time (UTC) and print the result hoping that's the local time of that specific country. For some reasons the result is wrong. For example with Hungary there is one hour difference. Any idea why I'm getting incorrect r

    Convert UTC to "local" time in Go
  • https://qiita.com/nyarla/items/9e0e54b12d31bb9b352b

  • Golang XML Unmarshal and time.Time fields

    I have XML data I am retrieving via a REST API that I am unmarshal-ing into a GO struct. One of the fields is a date field, however the date format returned by the API does not match the default time.Time parse format and thus the unmarshal fails. Is there any way to specify to the unmarshal function which date format to use in the time.Time parsing? I'd like to use properly defined types and usin

    Golang XML Unmarshal and time.Time fields
  • 逆引きGolang (日付と時刻)

    現在の時刻を取得する 時刻オブジェクトを作成する 時刻を任意のフォーマットで扱う 時刻オブジェクトを文字列に変換する 時刻に任意の時間を加減する 2つの時刻の差を求める 時刻中の曜日を日語に変換する UNIXタイムをTimeオブジェクトに変換する 現在の日付を求める 日付オブジェクトを文字列に変換する 日付オブジェクトを作成する 指定の日付が存在するかどうか調べる ユリウス日から日付オブジェクトを作成する 何日後、何日前の日付を求める 何ヶ月後、何ヶ月前の日付を求める うるう年かどうか判定する 日付オブジェクトの年月日・曜日を個別に扱う 文字列の日付を日付オブジェクトに変換する 現在の時刻を取得する package main import "fmt" import "time" func main() { t := time.Now() fmt.Println(t) // => "201

  • Big Sky :: Go言語で日付処理

    元ネタ: 誰もが一度は陥る日付処理。各種プログラミング言語におけるDateTime型/TimeStamp型の変換方法のまとめ Go言語が無かったので書いてみた。 現在時刻の取得 package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now()) } 2013-06-19 21:46:14.186298 +0900 +0900 Time => Unix時刻変換 package main import ( "fmt" "time" ) func main() { fmt.Println(time.Now().Unix()) } 1371646123 Unix時刻 => Time変換 package main import ( "fmt" "time" ) func main() { fmt.Println(tim

    Big Sky :: Go言語で日付処理
  • GAE/Goのハマったところ(´・ω・`) - Qiita

    2016.12 追記: 記事はGAEのGo SDKに特化した内容です。 GAE全般については↓に記事を書きました。 GAEでハマったこと(´・ω・`) 2014年は半年くらいGoogle App Engine(GAE)/Goのアプリを書く事に費やすことが出来て、とても幸せな一年でした(^^) GAE/Goはご存知の通りずっとbeta(or experimental) (2015/7に正式リリースされました!\(^o^)/)ですが、個人的にはGAEランタイムの中で最強だと思っています。 何よりspin-upが早い!リクエストの処理もgoroutineでシンプルに高速化出来る!GAEアプリ書くならGoを選ばない理由はない!と思っています。 とは言え書籍や情報の少ないGAE/Goの開発、少なからずハマった箇所もありましたのでそれを技術不足露呈も覚悟の上で共有したいと思います。 あ、GAEに興味

    GAE/Goのハマったところ(´・ω・`) - Qiita
  • 1