diff --git a/pkg/s3/bucket.go b/pkg/s3/bucket.go index b2534fd7..4ce4a789 100644 --- a/pkg/s3/bucket.go +++ b/pkg/s3/bucket.go @@ -1,3 +1,40 @@ +// Original license // +// ---------------- // + +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// All other modifications and improvements // +// ---------------------------------------- // + +/* + * Mini Object Storage, (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package s3 import ( diff --git a/pkg/s3/client.go b/pkg/s3/client.go index a70349ce..47687ffb 100644 --- a/pkg/s3/client.go +++ b/pkg/s3/client.go @@ -46,25 +46,15 @@ import ( "net/http" "regexp" "strings" - "time" "encoding/xml" ) -// Date format -const ( - xmlTimeFormat = "2006-01-02T15:04:05.000Z" -) - // Total max object list const ( MaxKeys = 1000 ) -type xmlTime struct { - time.Time -} - // Client is an Amazon S3 client. type Client struct { *Auth @@ -100,24 +90,6 @@ type listBucketResults struct { CommonPrefixes []*Prefix } -func (c *xmlTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { - var v string - d.DecodeElement(&v, &start) - parse, _ := time.Parse(xmlTimeFormat, v) - *c = xmlTime{parse} - return nil -} - -func (c *xmlTime) UnmarshalXMLAttr(attr xml.Attr) error { - t, _ := time.Parse(xmlTimeFormat, attr.Value) - *c = xmlTime{t} - return nil -} - -func (c *xmlTime) format() string { - return c.Time.Format(xmlTimeFormat) -} - func (c *Client) transport() http.RoundTripper { if c.Transport != nil { return c.Transport diff --git a/pkg/s3/error.go b/pkg/s3/error.go index 75fb30c4..b4635722 100644 --- a/pkg/s3/error.go +++ b/pkg/s3/error.go @@ -1,3 +1,40 @@ +// Original license // +// ---------------- // + +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// All other modifications and improvements // +// ---------------------------------------- // + +/* + * Mini Object Storage, (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package s3 import ( diff --git a/pkg/s3/object.go b/pkg/s3/object.go index 73e16665..090e1075 100644 --- a/pkg/s3/object.go +++ b/pkg/s3/object.go @@ -1,3 +1,40 @@ +// Original license // +// ---------------- // + +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// All other modifications and improvements // +// ---------------------------------------- // + +/* + * Mini Object Storage, (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package s3 import ( diff --git a/pkg/s3/xmltime.go b/pkg/s3/xmltime.go new file mode 100644 index 00000000..dfc187af --- /dev/null +++ b/pkg/s3/xmltime.go @@ -0,0 +1,71 @@ +// Original license // +// ---------------- // + +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// All other modifications and improvements // +// ---------------------------------------- // + +/* + * Mini Object Storage, (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package s3 + +import ( + "time" + + "encoding/xml" +) + +// Date format +const ( + xmlTimeFormat = "2006-01-02T15:04:05.000Z" +) + +type xmlTime struct { + time.Time +} + +func (c *xmlTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var v string + d.DecodeElement(&v, &start) + parse, _ := time.Parse(xmlTimeFormat, v) + *c = xmlTime{parse} + return nil +} + +func (c *xmlTime) UnmarshalXMLAttr(attr xml.Attr) error { + t, _ := time.Parse(xmlTimeFormat, attr.Value) + *c = xmlTime{t} + return nil +} + +func (c *xmlTime) format() string { + return c.Time.Format(xmlTimeFormat) +} diff --git a/s3-fs-ls.go b/s3-fs-ls.go index 5536fc4c..a3e9d0f2 100644 --- a/s3-fs-ls.go +++ b/s3-fs-ls.go @@ -26,13 +26,9 @@ import ( "github.com/minio-io/mc/pkg/s3" ) -const ( - humanReadableFormat = "2006-01-02 15:04:05" -) - func printBuckets(v []*s3.Bucket) { for _, b := range v { - msg := fmt.Sprintf("%v %9s %s", b.CreationDate.Format(humanReadableFormat), "", b.Name) + msg := fmt.Sprintf("%v %9s %s", b.CreationDate.Local(), "", b.Name) info(msg) } } @@ -47,7 +43,7 @@ func printObjects(v []*s3.Item) { } func printObject(date time.Time, v int64, key string) { - msg := fmt.Sprintf("%v %9s %s", date.Format(humanReadableFormat), pb.FormatBytes(v), key) + msg := fmt.Sprintf("%v %9s %s", date.Local(), pb.FormatBytes(v), key) info(msg) }