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

learn more… | top users | synonyms

3
votes
3answers
298 views

Convert a date string to a DateTime object in C#

I was just wondering if my code contains defects or if there was a more efficient or general way to convert string to DateTime object. In the input, I have a string ...
9
votes
5answers
367 views

Birthday validity-checking

I have written code to check any birthday input's validity. As I am new in programming, and after going through several debugging steps, the code became very ugly. ...
0
votes
0answers
21 views

Extend date comparison function in Angular to take different dates as parameters [closed]

I have an angular function which passes in two date objects and compares them returning one of two strings which are then passed as a class name to an html element. The idea being that if the date is ...
7
votes
1answer
73 views

Small Calendar “Widget”

I have been working on a calendar widget for the past hour or so. I wonder if it could be compacted any more than it already is (ignoring whitespace). ...
12
votes
2answers
128 views

Mengenlehreuhr in Python

Telling the time based on the "set theory principle", the Mengenlehreuhr consists of 24 lights which are divided into one circular blinking yellow light on top to denote the seconds, two top ...
-1
votes
2answers
52 views

Extracting a date and time from a log file

I am trying to make my code as legible as possible, and today I wrote the following snippet and I'm unsure as to whether it can be improved in an obvious way. There's always room for improvement, of ...
7
votes
5answers
519 views

Return Nth Weekday of Month

My goal is to obtain the nth weekday of a given month. Parameters are a date from a given month and the nth weekday I'm trying to obtain. It returns the Nth Weekday of the month if it exist and ...
1
vote
0answers
47 views

Updating datetime fields from UTC to local time zone

I have created an SQL query to update datetime fields from UTC to local time zone. Can someone review this? ...
4
votes
0answers
54 views

Datepickers for departure and return dates

I have to two datepickers. I want achieve a following functionality: when return date cannot be selected before departure and departure cannot be after return date. Mainly I am interested in ...
4
votes
1answer
41 views

Deleting most recent files by parsing filename

I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different ...
4
votes
2answers
78 views

Calculating German common holidays

I wrote a simple dll which is able to calculate all common holidays, but, I would like to optimize the code in readability and flexibility. Federal state ...
5
votes
2answers
56 views

Writing a utility class for converting between datetime and timestamp

I'm writing an Python application that uses frequently datetime and Unix timestamp. I know Python is 'batteries included', however, I found that converting between datetime and timestamp in Python 2.6 ...
2
votes
2answers
70 views

Date formatters, lazily instantiated once

I would like to create two date formatters only on first call. In Objective-C I would use dispatch_once() but now working in Swift. Am I doing it correctly? My code ...
4
votes
1answer
84 views

WPF DateTimePicker user control

I've created a UserControl that should act as a control inside a Window: XAML: ...
1
vote
1answer
50 views

Countdown script

I made a script in JavaScript to calculate how long it takes until a certain date. Do you find it user-friendly enough? Is the code correct? ...
1
vote
2answers
58 views

Listing every date between two dates in input fields

Using the following HTML: <input type="date" value="2015-07-26" name="startdate"> <input type="date" value="2015-07-29" name="enddate"> First, the JS ...
2
votes
3answers
46 views

Transforming data from an array of objects to a nested array of objects

I have an array of objects where each object has a datetime key/value pair: ...
2
votes
4answers
55 views

Parsing time if valid

I need to parse only valid timestamp formats: Hours followed by minutes followed by seconds: t=1h2m3s Minutes followed by seconds: ...
6
votes
1answer
70 views

Bucketizing time (e.g., 4 min => 0-5 min)

Specification: Given a string (e.g., the content of an article), print the estimated reading time by bucketizing time into increasingly large chunks in the form "5-10 min" or "48 min-2 hr". ...
4
votes
1answer
54 views

How much time is left?

rags-to-riches of Convert seconds to hours, minutes and seconds. In that question, BigDecimal was chosen to be the model class, which doesn't seem like a right fit ...
5
votes
2answers
100 views

Every year is like a loop. A nasty, nested one

Quite a little while ago, I wrote a VBA macro to generate fiscal calendar date records. That macro did the job all this time, but I needed to be able to generate fiscal years from an ETL overnight ...
9
votes
5answers
342 views

Prorated Refund Calculator (v2)

This is a follow-up question to original Prorated Refund Calculator. Here is the summary of the changes I made since last, thanks to the good answers and some study of my own. Did away with ...
-6
votes
1answer
73 views

Date Range Tree

...
4
votes
4answers
278 views

Alarm clock printing

I know there must be an easier way to write this but I'm stuck in over-complicating mindset instead of just following the Zen of Python. Please help me simplify this. Given a day of the week ...
4
votes
5answers
1k views

Leap year check in Java

I'm looking for 3 different answers: Using Java predefined functions Converting from string to number Without the above two (any other types of answers are also welcome) I am looking for improving ...
2
votes
1answer
42 views
1
vote
1answer
40 views

Get Next and Previous “Load Day”

I keep looking at this trying to figure if there's a better way. All three functions work, but I wanted to get some insights and ideas from others. IsLoadDay ...
1
vote
3answers
49 views

Date composition from day, month and year input

I need to concatenate 3 input fields into a string which is formatted as a date dd-mm-yyyy, using type="date" or ...
4
votes
2answers
65 views

Getting all the UTC “day stamps” between 2 dates

I need to get every UTC day stamp in yyyy-MM-dd format (e.g. "2015-07-02") between any two arbitrary Date fields. My first attempt is this: ...
0
votes
3answers
44 views

Rewriting hours

I am just trying to rewrite hours; say 1:24PM, if 24 > 30 then it is 2PM, otherwise it is 1PM. I really doubt that I am doing it right, first I am sure it looks so amateur, second I am not sure if it ...
3
votes
1answer
82 views

Naming request for a class to return a different value every so often

I have a class that I'm trying to determine a good name for. I don't know if this concept comes up a lot in programming or not, but I'm wondering if I can get some suggestions for a good name for the ...
11
votes
4answers
492 views

Compute the day of the year

I am new to programming. I saw this Java code with a lot of if-else statements that is copied below. People say that such a code ...
5
votes
2answers
53 views

Conditionals for time specific data (SQL style)

I was inspired by this question from @AndyRoid to try and come up with some fast and accurate datetime calculations that didn't involve complex if/...
7
votes
6answers
425 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
2
votes
3answers
300 views

Find number of whole weeks between months in the same year

I wrote a class to return the number of whole weeks between months in the same year. I need suggestions on my code. ...
3
votes
1answer
42 views

Date validation with html5 dates

This code validates the following: enddate should not be less than or equal to startdate. ...
0
votes
0answers
30 views

Dynamic/Global Business Days Calculation

I have a problem in that I need a formula which calculates business days around the world. For example, in the UK we have 5 day weeks, but in the Middle East they have 6 day weeks. Also, perhaps we ...
4
votes
1answer
70 views

Game boot to some operations every second

I am building game, like Ogame, or Ikariam where you can play with other users in real-time. You train some soldiers, and build some vehicles or buildings. Every building or vehicle has some level. If ...
7
votes
3answers
194 views

Colorizing Excel cells with a date range filter

In a table there is a number of column (chambre) and a number of row (alveole). If these matches in a list in an other sheet then it checks if it the date is between two dates on that second sheets. ...
3
votes
1answer
59 views

Projecting future positions

My code takes a starting position (which must be completed) and a list of updates (each element of which is optional). It then projects future positions, using the appropriate value from each update, ...
4
votes
2answers
116 views

Calculate amount of seconds from user birth date to beginning of current year

I'm trying to make a program where user will put in his birth date in DD/MM/YYYY form and he will get back amount of seconds between his birth day and 01/01/2015. It counts with fact that different ...
2
votes
1answer
84 views

Get Elapsed Time as Human Friendly String

In lieu with several other Facebook-esque concepts I am trying to replicate, this working code will take the span of time from a given date to now, and try to convert it into the most convenient ...
2
votes
2answers
81 views

Getting hours during the day

I have this method that returns an array of all the hours for the past 24 hours, ex: if the current time is 3:24pm it looks like @[3pm,4pm...12am,1am...2pm,3pm]; ...
6
votes
1answer
62 views

Find the next 8 dates that are Mondays (exclusive of today)

Any thoughts on improving this method of finding the next 8 Mondays not including today? ...
2
votes
0answers
50 views

An implementation of `ago()` in PHP

Here is my code for the string ago(int timestamp) function: Bitbucket snippet ...
2
votes
1answer
40 views

Running alarms in python

My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. ...
2
votes
2answers
104 views

Build a time struct for current time in UTC

I'm learning about time structs. Without assigning either in code or input routines I want the current time. Please help me refactor this, if it should be. This code just tries to make a time struct ...
2
votes
1answer
54 views

Net health monitoring

This is a little net health monitoring project I made in NodeJS. It pings google every second and stores the result (true/false) along with the date in a database (MongoDB). I've collected enough ...
3
votes
1answer
91 views

Extracting opening and closing times for each day of the week

I have these two methods: ...
11
votes
2answers
117 views

Prorated refund calculator

I wrote this little piece of script for my workplace (insurance, etc.) to help our admins, as a light and simple file I can just email to my colleagues. The purpose of it is to calculate a prorated ...