All Projects → fumiyasac → handMadeCalendarAdvance

fumiyasac / handMadeCalendarAdvance

Licence: MIT license
[ING]Swift版の日本の祝祭日判定コードとカレンダーサンプル(iOS Sample Study: Swift)

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to handMadeCalendarAdvance

Cvcalendar
A custom visual calendar for iOS 8+ written in Swift (>= 4.0).
Stars: ✭ 3,435 (+5440.32%)
Mutual labels:  calendar-component
React Native Persian Calendar Picker
Persian Calendar Picker Component for React Native
Stars: ✭ 83 (+33.87%)
Mutual labels:  calendar-component
Eventscalendar
Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project!
Stars: ✭ 188 (+203.23%)
Mutual labels:  calendar-component
Pmcalendar
Yet another calendar component for iOS. Compatible with iOS 4.0 (iPhone & iPad) and higher. Supports presenting as a popover and very flexible UI tuning. Default theme is inspired by https://github.com/ocrickard/OCCalendar
Stars: ✭ 383 (+517.74%)
Mutual labels:  calendar-component
Yycalendar
Simple and Clear Calendar
Stars: ✭ 46 (-25.81%)
Mutual labels:  calendar-component
Calendar Ios
Calendar View
Stars: ✭ 154 (+148.39%)
Mutual labels:  calendar-component
Primedatepicker
PrimeDatePicker is a tool that provides picking a single day, multiple days, and a range of days.
Stars: ✭ 292 (+370.97%)
Mutual labels:  calendar-component
Customizablecalendar
CustomizableCalendar is a library that allows you to create your calendar, customizing UI and behaviour
Stars: ✭ 214 (+245.16%)
Mutual labels:  calendar-component
Recyclercalendarandroid
A simple DIY library to generate your own custom Calendar View using RecyclerView, written in Kotlin
Stars: ✭ 83 (+33.87%)
Mutual labels:  calendar-component
Vacalendar
Custom Calendar for iOS in Swift
Stars: ✭ 184 (+196.77%)
Mutual labels:  calendar-component
Calendarview
An Easy to Use Calendar for iOS (Swift 5.0)
Stars: ✭ 429 (+591.94%)
Mutual labels:  calendar-component
Calendarview
Android上一个优雅、万能自定义UI、仿iOS、支持垂直、水平方向切换、支持周视图、自定义周起始、性能高效的日历控件,支持热插拔实现的UI定制!支持标记、自定义颜色、农历、自定义月视图各种显示模式等。Canvas绘制,速度快、占用内存低,你真的想不到日历居然还可以如此优雅!An elegant, highly customized and high-performance Calendar Widget on Android.
Stars: ✭ 7,998 (+12800%)
Mutual labels:  calendar-component
Xamarin.plugin.calendar
Calendar plugin for Xamarin.Forms
Stars: ✭ 159 (+156.45%)
Mutual labels:  calendar-component
React Timeline Gantt
A react Timeline component with virtual rendering
Stars: ✭ 347 (+459.68%)
Mutual labels:  calendar-component
Angular Calendar
A calendar component for Angular 12.0+ that can display events on a month, week or day view. The successor of angular-bootstrap-calendar.
Stars: ✭ 2,312 (+3629.03%)
Mutual labels:  calendar-component
Vue Functional Calendar
Vue.js Functional Calendar | Component/Package
Stars: ✭ 314 (+406.45%)
Mutual labels:  calendar-component
Date Picker
Duet Date Picker is an open source version of Duet Design System’s accessible date picker. Try live example at https://duetds.github.io/date-picker/
Stars: ✭ 1,325 (+2037.1%)
Mutual labels:  calendar-component
praecox-datepicker
A date picker built with Svelte.Simple and flexible, supporting functions such as single selection, multiple selection, disabling, and marking.
Stars: ✭ 66 (+6.45%)
Mutual labels:  calendar-component
Recal
A minimal, accessible React/Preact calendar component using modern CSS.
Stars: ✭ 191 (+208.06%)
Mutual labels:  calendar-component
Vue Hash Calendar
移动端日期、时间选择插件,日期选择面板以日历形式展示。上下滑动切换周/月模式。支持两种模式:1,月模式,左右滑动切换月份。2、周模式,左右滑动切换周。
Stars: ✭ 163 (+162.9%)
Mutual labels:  calendar-component

handMadeCalendarAdvance(CalculateCalendarLogic)

This library CalculateCalendarLogic (sample project name is handMadeCalendarAdvance) can judge a holiday in Japan.

Description

This library 'CalculateCalendarLogic' can judge a holiday in Japan. When you use this library, you can judge can judge a holiday in Japan very easily. A method which named 'judgeJapaneseHoliday' method stores variables year, month, and day in an argument, it returns true or false.

About CalculateCalendarLogic.swift

/* CalculateCalendarLogic.swift */

public func judgeJapaneseHoliday(year: Int, month: Int, day: Int) -> Bool {

    /**
     *
     * - Description judge japanese holiday
     * - parameter year: year value (Int)
     * - parameter month: month value (Int)
     * - parameter day: day value (Int)
     * - returns: result (Bool)
     */

     // judge holiday logic...
}

Requirements & Support

  • iOS 13.0 or later
  • macOS 11.0 or later

Installation

We can use this library with CocoaPods, Carthage, Swift Package Manager, Manually.

Use CocoaPods

Create Podfile and specify it in your Podfile:

★ Example of Podfile

platform :ios, '13.0'
use_frameworks!
target [YOUR PROJECT NAME]' do
  pod 'CalculateCalendarLogic'
end
Use Carthage

Create Carthage and specify it in your Cartfile:

★ Cartfile

github "fumiyasac/handMadeCalendarAdvance"
Use Swift Package Manager

Using Xcode, go to File -> Swift Packages -> Add Package Dependency and enter URL below: https://github.com/fumiyasac/handMadeCalendarAdvance

Manually

Copy all the files in CalculateCalendarLogic/CalculateCalendarLogic.swift file into your project.

Author

fumiyasac(Fumiya Sakai)

Example

It's as below.

/* ViewController.swift */

// Step1: import CalculateCalendarLogic (If you install manually, you don't need import statement.)
import CalculateCalendarLogic

// Step2: create instance of CalculateCalendarLogic
let holiday = CalculateCalendarLogic()
...

// Step3: input year, month and day values into judgeJapaneseHoliday method.
let result: Bool = holiday.judgeJapaneseHoliday(year: 2016, month: 1, day: 1)

// Result:
print("2016 January 1:\(result)")

//You will display「2016 January 1:true」in your Xcode console.

License

MIT

Contributor

Special Thanks to

and more iOS developers.

handMadeCalendarAdvance(CalculateCalendarLogic)

Swift版の日本の祝祭日判定コードとカレンダーライブラリとサンプル

サンプル表示例

日本の祝祭日の判定ロジックとそのロジックを活用したカレンダーサンプルの例になります。 (※ 計算ロジックの実態部分はCalculateCalendarLogic.swiftを参照)

概要

日本の祝祭日(振替休日)を判定する構造体を作成しました。 使い方に関してはCalculateCalendarLogic.swiftをお使いのプロジェクトにコピーし、下記の「使い方」を参考に記述をして頂くとご利用になれます。 その他のカレンダーアプリを作成する際やお使いのアプリでご活用して頂ければ幸いです。

このライブラリの内部仕様について

下記のようにjudgeJapaneseHolidayメソッドに年・月・日を引数として渡すことでその日が祝祭日(振替休日)であるかを判定します。 戻り値はBool型で返却して判定できるようにしています。

/* CalculateCalendarLogic.swift */

public func judgeJapaneseHoliday(year: Int, month: Int, day: Int) -> Bool {

    /**
     *
     * 祝日になる日を判定する
     * (引数) year: Int, month: Int, day: Int
     * weekdayIndexはWeekdayのenumに該当する値(0...6)が入る
     * 参考資料1. カレンダーロジックの参考                      :http://p-ho.net/index.php?page=22
     * 参考資料2. 書き方(タプル)の参考                        :http://blog.kitoko552.com/entry/2015/06/17/213553
     * 参考資料3. [Swift] 関数における引数/戻り値とタプルの関係 :http://dev.classmethod.jp/smartphone/swift-function-tupsle/
     *
     */

     // 実装は実際のクラスを参照して頂ければ幸いです。
}

対応バージョンとサポート

  • iOS 13.0 or later
  • macOS 11.0 or later

導入方法

このライブラリはCocoaPods・Carthage・Swift Package Manager及び手動での追加に対応しています。

CocoaPodsでの追加

プロジェクト内にPodfileを作成し下記のように記述をして下さい。

★ Podfileの記述例

target '[自分のプロジェクト名]' do
  use_frameworks!
  pod 'CalculateCalendarLogic'
end
Carthageでの追加

プロジェクト内にCartfileを作成し下記のように記述をして下さい。

★ Cartfileの記述

github "fumiyasac/handMadeCalendarAdvance"

参考:Carthageを使った外部ライブラリ導入方法

Swift Package Managerでの追加

お使いのXcodeで「File -> Swift Packages -> Add Package Dependency」と進み、後述するURLを入力してEnterキーを押下して下さい。 https://github.com/fumiyasac/handMadeCalendarAdvance

手動での追加

また手動でライブラリファイルを追加する場合には、CalculateCalendarLogic.swiftファイルをご自身のプロジェクトに追加して下さい。

導入例:ライブラリを使わないカレンダーサンプル

Author

fumiyasac(Fumiya Sakai)

プロジェクトでの実装例

下記のように判定したい年・月・日を引数にセットするだけでOKです。

/* ViewController.swift */

// Step1: ライブラリのインポート(手動で導入した場合は不要)
import CalculateCalendarLogic

// Step2: CalculateCalendarLogicのインスタンスを作成
let holiday = CalculateCalendarLogic()
...

// Step3: 使用する際は引数を入れての判定を行う
let result: Bool = holiday.judgeJapaneseHoliday(year: 2016, month: 1, day: 1)

// 実行結果
print("2016年1月1日:\(result)")

//コンソールでは「2016年1月1日:true」と表示されます

本実装ではBool型での判定ではありますが、このメソッドをカスタマイズして戻り値を変更して「祝祭日の判定&祝祭日名を返す」ようにする等の用途に応じてのカスタマイズも可能です。

テストケース等その他

現行プログラムでCalculateCalendarLogic.swiftで考慮したテストケースは下記の通りです。

  • 今年(2016年〜2022年)の祝祭日の判定が正しく行えていること
  • ゴールデンウィークの判定が正しく行えていること(※サンプル:2017年/2019年/2021年)
  • シルバーウィークの判定が正しく行えていること(※サンプル:2015年/2026年/2032年)
  • 春分の日・秋分の日の判定が正しく行えていること(※サンプル:2000年〜2030年)

テストケースに関しては今後追加予定です。

ライセンス

MIT

更新履歴

まだまだ甘い部分があるかもしれませんが、その際はPullRequest等を送っていただければ幸いです。アプリ開発の中でこのサンプルが少しでもお役にたつ事ができれば嬉しい限りです。

  • 2023.01.01: 保守対応&iOS16で利用可能なUICalendarViewのサンプル追加を行いました。
  • 2021.06.05: Gihub Actions追加(uhooi様)
  • 2020.12.02: Xcode12.2への対応/2021年の祝日に関する追加対応/サンプルコード修正等を行いました。
  • 2019.06.26: Swift5.0及びXcode10.2.1への対応を行いました。
  • 2019.01.23: 2019年の祝日に関する追加対応を行いました(kazuomatz様)。
  • 2018.12.02: Swift4.2及びXcode10への対応を行いました。
  • 2018.08.08: 2020年のカレンダーへの対応を行いました(myammm様)。
  • 2018.07.04: Swift4.1及びXCode9.4への対応を行いました(essochi様)。
  • 2017.10.10: Swift4及びXCode9への対応を行いました。
  • 2017.01.14: macOS10.10と以降バージョンへのサポートが可能になりました。
  • 2016.12.31: 最新版をCocoaPods & Carthageへの対応を行いました。
  • 2016.12.29: Swift3系への対応を行いました。
  • 2016.10.13: Swift2.3及びSwift3.0ブランチ作成
  • 2016.09.03: CocoaPodsへの対応をしました(ドキュメント修正や追記含む)
  • 2016.05.28: READMEに追記をしました(Carthageで導入する際の手順や文章の修正等)
  • 2016.05.09: カレンダーに実装した例を掲載しました(UICollectionViewを使用)
  • 2016.05.01: CalculateCalendarLogic.swiftの実装と祝祭日判定テストケースを追加

謝辞

このライブラリの作成にあたりakio0911様、akuraru様、keygx様、econa77様、kazuomatz様、essochi様、myammm様、uhooi様をはじめ皆様からの多くのアドバイスやお力添えを頂きまして誠にありがとうございました。 また、プルリクエスト等を定期的に頂けることで本当に助かっております。

参考

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].