From 3c6c9f0681210bf60859f8b6bac16bbc16dc2abe Mon Sep 17 00:00:00 2001 From: Glenn Date: Tue, 16 Aug 2022 21:33:02 +0200 Subject: [PATCH] Initial import --- .editorconfig | 9 +++++++++ .gitignore | 5 +++++ .travis.yml | 6 ++++++ LICENSE | 21 +++++++++++++++++++++ Makefile | 37 +++++++++++++++++++++++++++++++++++++ README.md | 27 +++++++++++++++++++++++++++ shard.yml | 19 +++++++++++++++++++ spec/kathmandu_time_spec.cr | 9 +++++++++ spec/spec_helper.cr | 2 ++ src/kathmandu_time.cr | 32 ++++++++++++++++++++++++++++++++ 10 files changed, 167 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 shard.yml create mode 100644 spec/kathmandu_time_spec.cr create mode 100644 spec/spec_helper.cr create mode 100644 src/kathmandu_time.cr diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..163eb75 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.cr] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0bb75ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/docs/ +/lib/ +/bin/ +/.shards/ +*.dwarf diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..765f0e9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: crystal + +# Uncomment the following if you'd like Travis to run specs and check code formatting +# script: +# - crystal spec +# - crystal tool format --check diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..95d8235 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Glenn Y. Rolland + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..209f7ac --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ + +SOURCES=$(shell find -name '*.cr') + +LDFLAGS= +DESTDIR=/usr + +BUILDDIR=_build + +all: build + +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +$(BUILDDIR)/kathmandu_time: $(BUILDDIR) $(SOURCES) + crystal build $(LDFLAGS) src/kathmandu_time.cr -o $(BUILDDIR)/kathmandu_time + +build: $(BUILDDIR)/kathmandu_time + +build-release: LDFLAGS=--release --no-debug +build-release: build + +install: build + install -m 0755 -o root -g root \ + $(BUILDDIR)/kathmandu_time \ + $(DESTDIR)/bin/kathmandu_time + +spec: + crystal spec + +test: spec + +run: + crystal run src/kathmandu_time.cr + +clean: + rm -f $(BUILDDIR)/kathmandu_time + diff --git a/README.md b/README.md new file mode 100644 index 0000000..334f364 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# . + +TODO: Write a description here + +## Installation + +TODO: Write installation instructions here + +## Usage + +TODO: Write usage instructions here + +## Development + +TODO: Write development instructions here + +## Contributing + +1. Fork it () +2. Create your feature branch (`git checkout -b my-new-feature`) +3. Commit your changes (`git commit -am 'Add some feature'`) +4. Push to the branch (`git push origin my-new-feature`) +5. Create a new Pull Request + +## Contributors + +- [Glenn Y. Rolland](https://github.com/glenux) - creator and maintainer diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..8d37607 --- /dev/null +++ b/shard.yml @@ -0,0 +1,19 @@ +name: kathmandu_time +version: 0.1.0 + +# authors: +# - name + +# description: | +# Short description of kathmandu_time + +# dependencies: +# pg: +# github: will/crystal-pg +# version: "~> 0.5" + +# development_dependencies: +# webmock: +# github: manastech/webmock.cr + +# license: MIT diff --git a/spec/kathmandu_time_spec.cr b/spec/kathmandu_time_spec.cr new file mode 100644 index 0000000..7ff3638 --- /dev/null +++ b/spec/kathmandu_time_spec.cr @@ -0,0 +1,9 @@ +require "./spec_helper" + +describe KathmanduTime do + # TODO: Write tests + + it "works" do + false.should eq(true) + end +end diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..87a195a --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1,2 @@ +require "spec" +require "../src/." diff --git a/src/kathmandu_time.cr b/src/kathmandu_time.cr new file mode 100644 index 0000000..9f5e16c --- /dev/null +++ b/src/kathmandu_time.cr @@ -0,0 +1,32 @@ +# TODO: Write documentation for `KathmanduTime` +module KathmanduTime + VERSION = "0.1.0" +end + +require "time" + +if ARGV.size < 1 + STDERR.puts "ERROR: please give a french time (GMT+1)" + exit 1 +end + +time = ARGV[0] + +now = Time.utc + +paris_now = Time.local +paris_offset = paris_now.to_s("%:z") + +paris_tz = Time::Location.load("Europe/Paris") +kath_tz = Time::Location.load("Asia/Kathmandu") + +# puts (paris_tz.zones +# .select{ |t| t.dst? } +# .map {|t| t.format(true, false) } +# ).inspect + +paris_time = Time.parse("#{time} #{paris_offset}", "%H:%M %z", location: paris_tz) +kath_time = paris_time.in(kath_tz) + +puts "Paris: #{paris_time.to_s("%H:%M %:z")}" +puts "Kathmandu: #{kath_time.to_s("%H:%M %:z")}"