DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.

learn more… | top users | synonyms

4
votes
1answer
121 views

Leap year calculator

I'm creating a program to determine whether or not a given year is a leap year. I just wanted to get anyone's feedback on it. I am aware of the calendar module in Python. I just wanted to try it from ...
4
votes
0answers
17 views

Access function to return “number of working days until date” for form

I need a function I can put on a form which does: Calculates number of working days until a given date Excludes weekends Excludes any dates in a "holiday" table This is replacing something which ...
6
votes
2answers
42 views

Generating fiscal calendar dates

I need to generate a T-SQL script for loading data into this table: ...
1
vote
1answer
19 views

Assorted Date Parser

I've written a date parser that parses different types of dates using Parsec. Credit for the original problem goes to here. The following formats are as such: ...
4
votes
2answers
80 views

Implement a Clock in JavaScript

How idiomatic is my code? ...
1
vote
0answers
41 views

Handling hours, minutes, seconds

Basically I wanted to make a generic class for parsing time codes and dealing with small units of time. I have tried to keep it very simple (small API) and 0 dependency (apart from RSpec). Some ...
2
votes
2answers
41 views

Function to validate date format

I have this JavaScript function which checks if the format has 'yyyy' and replaces 'yy' with 'y': ...
3
votes
3answers
180 views

TimeZone computing method

I feel like there is a code smell in this. Can someone help me to refactor/optimize it? ...
3
votes
1answer
61 views

Generating all valid dates

I've come up with the following code to generate a list of all dates between two given dates: ...
1
vote
1answer
26 views

Cluster date time values

I came up with this TSQL for SQL Server 2008: ...
1
vote
1answer
36 views

Counting business days in a month, ignoring holidays

In the past, I have worked mostly in MySQL and SQL Server. Almost everything at my current job is Oracle, though. I could have written this instantly for MySQL but I could barely google what I ...
3
votes
3answers
288 views

DateTime-like class implementation in modern C++

In modern C++, there is no class like datetime in the standard which can be used in the program. However, with additional of modules like ...
1
vote
3answers
30 views

Determine numeric month based on actual moth

The following script uses a switch statement to determine the numeric month based on the actual month. Is there a more succinct way (read: elegant, or less time to write) to accomplish the same ...
3
votes
1answer
39 views

Compute adjacent days from date string

I'm trying to do some datetime processing. The input is a string of the form 20141005 ('%Y%m%d') and I want to return a data ...
3
votes
1answer
50 views

Checking for a date and compare 2 different files

From snippets around the web, I was able to put together this .bat file to check for a date and compare 2 different files. This works below but I want to clean it up so it can be much lighter and ...
4
votes
1answer
62 views

(Swedish) Calendar of the year 2015 using Firebase

I've made a calendar for the year of 2015 using Firebase for real-time updates when something changes in it. I'm quite happy with it but I'm interested in getting some feedback on my Javascripting ...
4
votes
1answer
47 views

Orthodox Easter calculator

I have code for calculating the date for orthodox Easter and it makes me cry when I look at the if-else part. Please give your ...
13
votes
2answers
107 views

It's Friday! - Zeller's Congruence Revisited

A couple of date-related questions have come up recently, and on both occasions I have been taken back to my 'early' days where one of my first forays in to programming involved implementing Zeller's ...
5
votes
1answer
166 views

Logging with date in Java

I write my log messages in JTextArea. Each message should have a time added. I created a following method: ...
14
votes
3answers
3k views

Is it Friday yet?

This is the first program that I have written in my C++ saga that I actually think is useful. The description for this assignment is kinda long and mundane though: Write a program that inputs a ...
5
votes
3answers
85 views

Summing some datum for requests in each domain that fall in a date range

I have a LINQ query which works fine. I am however very interested to understand if this can be written in a more optimum way... ...
1
vote
1answer
77 views

Least suprising extension methods for DateTime to NATO date-time group

I have the following code to get a NATO date-time group for a DateTime. I usually need Zulu-Time or from a specific time zone. Is it clear what those methods are providing? If want to parse a NATO dtg ...
7
votes
1answer
78 views

Filter out date records which don't fall within or span a date range

I have records which have specific time spans. The need is to select records which adhere to the following three rules (read them as or conditions) concerning a ...
4
votes
1answer
71 views

Fast regex to extract strings before and after a time

I want to get text1 and text2 by splitting time format Text1 10:24:02 Text2 Of the ...
7
votes
2answers
454 views

Find the number of working days between two dates inclusively

The objective is to find the number of working days (days spanning from Monday to Friday) between two given dates inclusively. ...
8
votes
0answers
65 views

Chrono-like clock with different epoch (from 1.1. 2000)

The following will by my simple helper, that should behave just like std::chrono::system_clock but with the epoch being 1.1. 2000, that I can easily cast durations ...
10
votes
5answers
683 views

Function for checking leap years

As part of one of my AP Computer Science labs, I was required to write a function to determine whether a year was a leap year or not. Included as comments are a few reasons why I did things, as well ...
6
votes
2answers
66 views

Leap year functionality in Ruby and JavaScript

I did a line-by-line translation and am wondering if the JavaScript code looks idiomatic. Original Ruby code: ...
2
votes
2answers
69 views

Determining the next payment renewal date

I am not very good a JavaScript, surely not date manipulation, but I hacked together the script below with the purpose to determine the next payment renewal date based on a start date and payment ...
5
votes
1answer
45 views

Using a TSV text file and map for a Q&A program

The program outputs a menu asking for a new question or to ask a question. If you ask a question, it will search a .tsv text file for the question and return the answer. It will then check a map that ...
3
votes
2answers
109 views

Designing a Time class [closed]

Problem Statement: 1. Design a class TIME which stores hour, minute and second. The class should have the methods to support the following: User may give the time value in 24-hour format. User may ...
1
vote
1answer
29 views

Observing PEP maximum line size, particularly when formatting localized timestamps

I have this function that I use to publish a message but I need to do this long conversion for time and date. Maybe there's a better way to convert it to make smaller. Otherwise I'm stuck with this ...
7
votes
3answers
68 views

Parsing dates from an OCR application

I wrote this code to parse dates from the output of the OCR, which means that the obtained date can be literally anything, so I put some restrictions in place: Date is the the format of: ...
7
votes
3answers
74 views

Calendar Print Method

I'm currently learning Ruby and need help in editing code to be more idiomatic. I have the method below I could use some pointers on how to make more "Ruby" :-) ...
1
vote
2answers
108 views

Weekly fee calculation

I have the following query. Its execution took 15 min and it's too much slow. Is there a way to optimize it? ...
6
votes
1answer
95 views

Dict of names and birth dates which prints with age at birthday of current year

As a beginner (Learn Python the Hard Way), I've set myself this exercise with classes and it works but looks very inelegant to me. I'm trying to write classes which could be re-used in other code. ...
1
vote
1answer
34 views

Using Regexp to select the date from a string [closed]

I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is ...
3
votes
1answer
50 views

Python Long UTC DateTime String

now = datetime.datetime.utcnow() now.strftime('%d %b %Y %I:%M:%S.%f')[:-3] + now.strftime(' %p') Is there a cleaner solution for this? I don't want the extra ...
4
votes
2answers
329 views

Converting numeric (month/day/year) date inputs to regular format (month day, year)

I'd really appreciate some general formatting/style/performance tips, as well as any ways I could improve this code in general that I wrote for an assignment (title) that's due at the end of the week. ...
4
votes
1answer
207 views

Cron expression validator for Apache Quartz

Not too long ago, I had to create a cron expression for a route in Apache Camel. I had a bit of a struggle to find the right expression. So I made a small program to output the n next valid dates ...
2
votes
1answer
76 views

How to send an email every half an hour if certain condition is met during that period?

I have my below method which will be called every one minute from the background thread. In my below code, if my unauthorizedCount and ...
5
votes
1answer
155 views

Extension methods for Daylight Savings Time dates

Just wondering if anyone had any suggestions for improvements. I created these extension methods so it's easier to get the start and end dates of Daylight Savings Time from the ...
3
votes
1answer
69 views

Read CSV with 3 columns and group some elements

I have a csv with 3 columns (date, name, number) and it is about 20K rows long. I want to create a dictionary keyed by date whose value is a dictionary of ...
6
votes
3answers
309 views

Time to Next Departure

I am trying to find out how many minutes that are remaining until the next train will departure, based on the current system time in Java. I am so far not familiar with the many aspects of Java, but ...
3
votes
3answers
320 views

Parsing and formatting a time two ways (perfectionistic approach)

I'm still not satisfied by the readability of the code. The wanted behavior which would be self descriptive would sound like: "I've two fields; one is for the date and one for the hour. This two ...
2
votes
1answer
63 views

Using datetime in order to name files

I have a script that makes use of datetime in order to name files. Only business days (Mon - Fri) are used. Here is my part of the code that finds the last ...
3
votes
2answers
882 views

Converting seconds to hours, minutes and seconds

The following question was taken from Absolute Java 5th ed. by Walter Savitch: Write a program that outputs the number of hours, minutes, and seconds that corresponds to 50,391 total seconds. The ...
10
votes
4answers
295 views

Ugly optimized caching of SimpleDateFormat

Concerning the optimization of this simple function String formatDate(String format, Locale locale, Date date) {...} formatting a ...
6
votes
3answers
414 views

Shutdown Delay Program

I wrote this program a while back that would allow me to set a delay, say 3 hours, and when the delay had expired, my PC would turn off. The purpose of it was so I didn't have to leave my PC on all ...
10
votes
1answer
90 views

Labor percentage and wages from clock in/out and sales records

I'm developing a PHP function for calculating labor percentage (labor cost/sales) accounting for daily and weekly overtime rules, if applicable, based on the payroll period; the wages for each ...