Initial import

This commit is contained in:
Glenn Y. Rolland 2022-08-16 21:33:02 +02:00
commit 3c6c9f0681
10 changed files with 167 additions and 0 deletions

9
.editorconfig Normal file
View file

@ -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

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf

6
.travis.yml Normal file
View file

@ -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

21
LICENSE Normal file
View file

@ -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.

37
Makefile Normal file
View file

@ -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

27
README.md Normal file
View file

@ -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 (<https://github.com/glenux/./fork>)
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

19
shard.yml Normal file
View file

@ -0,0 +1,19 @@
name: kathmandu_time
version: 0.1.0
# authors:
# - name <email@example.com>
# description: |
# Short description of kathmandu_time
# dependencies:
# pg:
# github: will/crystal-pg
# version: "~> 0.5"
# development_dependencies:
# webmock:
# github: manastech/webmock.cr
# license: MIT

View file

@ -0,0 +1,9 @@
require "./spec_helper"
describe KathmanduTime do
# TODO: Write tests
it "works" do
false.should eq(true)
end
end

2
spec/spec_helper.cr Normal file
View file

@ -0,0 +1,2 @@
require "spec"
require "../src/."

32
src/kathmandu_time.cr Normal file
View file

@ -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")}"