Skip to content

Instantly share code, notes, and snippets.

View nitin-agam's full-sized avatar
😎
Execution is the key 🔑

Nitin Aggarwal nitin-agam

😎
Execution is the key 🔑
View GitHub Profile
@nitin-agam
nitin-agam / CreditCardView.swift
Last active January 13, 2022 11:03
How to create credit card view using SwiftUI ?
struct CreditCardView: View {
var body: some View {
VStack(alignment: .leading, spacing: 20) {
HStack {
Text("Royale Gold Card")
.font(.system(size: 20, weight: .semibold, design: .monospaced))
Spacer()
Image("american_ex")
.resizable()
func isLeapYear(_ year: Int) -> Bool {
if year % 4 != 0 {
print("The year \(year) is not leap year because it is not evenly divisible by 4.")
return false
} else if year % 100 != 0 {
print("The year \(year) is a leap year because it is divisible by 4 and not by 100.")
return true
} else if year % 400 == 0 {
print("The year \(year) is a leap year because it is divisible by 400")
return true
@nitin-agam
nitin-agam / Time.Swift
Created April 6, 2023 14:46
Here is an example to convert seconds in display time format.
import Foundation
func formatDuration(_ durationInSeconds: Int) -> String {
let (hours, secondsAfterHours) = divmod(durationInSeconds, 3600)
let (minutes, seconds) = divmod(secondsAfterHours, 60)
return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
}
func divmod(_ numerator: Int,
_ denominator: Int) -> (quotient: Int, remainder: Int) {